Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento 1.7 - Custom module, call function
    primarykey
    data
    text
    <p>I created a custom module where i want to show some information about an product. In config.xml i added</p> <pre><code>&lt;blocks&gt; &lt;mymodule&gt; &lt;class&gt;Namespace_MyModule_Block&lt;/class&gt; &lt;/mymodule&gt; &lt;/blocks&gt; </code></pre> <p>The block class extends <strong>Mage_Catalog_Block_Product_View</strong>. But i can't call </p> <pre><code>$this-&gt;getProduct() </code></pre> <p>in the *.phtml file according to the module (mymodule.phtml). The xmls are configured well, so i can call the .phtml with </p> <pre><code>&lt;?php echo $this-&gt;getChildHtml('mymodule'); ?&gt; </code></pre> <p>but $product is always null. According to the configuration in modules config.xml $this->getProduct() should access Mynamespace_MyModule_Block_View and call the function. I tried with a dummy function which simply returns a string value, but this doesn't work either.</p> <p>I hope someone can give me a hint weather there is some missing or wrong configuration.</p> <p><strong>EDIT 1: Content of layout.xml</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;layout&gt; &lt;catalog_product_view&gt; &lt;reference name="product.info"&gt; &lt;block type="core/template" name="product_available_price" as="product_available_price" template="productavailable/price.phtml"/&gt; &lt;block type="core/template" name="product_available_info" as="product_available_info" template="productavailable/info.phtml"/&gt; &lt;block type="core/template" name="product_available_button" as="product_available_button" template="productavailable/button.phtml"/&gt; &lt;/reference&gt; &lt;/catalog_product_view&gt; &lt;/layout&gt; </code></pre> <p>In button.phtml i call $this->getProduct() and the method is in Mynamespace_MyModule_Block_Button</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload