title: update layout programmatically in magento event observer
body: <p>I am trying to change the template(view.phtml) of a block (<code>product.info</code>) for product detail page, to do this, I am observing an event (<code>controller_action_layout_generate_blocks_before</code>), in it after making necessary checks I am trying to change the template of the block (<code>product.info</code>) in following way:</p>
  
  <pre><code>$layout = $observer-&gt;getEvent()-&gt;getLayout();
  $layout-&gt;getUpdate()-&gt;addUpdate('
          &lt;reference name="product.info"&gt;
              &lt;action method="setTemplate"&gt;
                  &lt;template&gt;customlayout/product/view.phtml&lt;/template&gt;
              &lt;/action&gt;                                                          
          &lt;/reference&gt;');
  $layout-&gt;getUpdate()-&gt;load();
  $layout-&gt;generateXml();
  </code></pre>
  
  <p>If I put <code>"&lt;remove name='product.info'/&gt;"</code> , it will be removed but when trying to do the above, its not working.<br/>
  <strong>Edit:</strong> <br/>
  Requirement is to switch the template (product detail) dynamically to the selected one (in CustomModule) against the current product. </p>