1

I have added a zoom module which has added this below code to replace media.php file

<reference name="product.info">
        <action ifconfig="amzoom/general/enable" method="unsetChild"><name>product.info.media</name></action>
        <block type="amzoom/catalog_product_view_media"  name="product.info.media" as="media">
            <action method="setTemplate">
                <template>catalog/product/view/media.phtml</template> 
            </action>
            <action method="setTemplate" ifconfig="amzoom/general/enable">
                <template>amasty/amzoom/media.phtml</template>
            </action>
        </block>
    </reference>
</catalog_product_view>

Now i want one of the product (id=779) to use media-custom-hood.phtml file instead of amasty/amzoom/media.phtml.

and this is what i tried below with product_id layout handle

<PRODUCT_779>
   <reference name="product.info.media">
            <action method="setTemplate"> <!--/ ifconfig="amzoom/general/enable" -->
                <template>catalog/product/view/media-custom-hood.phtml</template>
            </action>
        </reference>
    </PRODUCT_779>

Also

 <PRODUCT_779>
        <reference name="product.info">
            <reference name="product.info.media">
                <block type="amzoom/catalog_product_view_media"  name="product.info.media" as="media">
                    <action method="setTemplate" ifconfig="amzoom/general/enable">
                        <template>catalog/product/view/media-custom-hood.phtml</template>
                    </action>
                </block>
            </reference>
        </reference>
</PRODUCT_779>

but it's not replacing that amasty/amzoom/media.phtml from external module

  • Initially try to add inside < PRODYCT_779 > something like < remove name="footer" /> to verify is it used or not. (Don't forget to remove spaces) – zhartaunik Feb 15 '16 at 8:28
  • @zhartaunik it's used and was replacing the default media.phtml file before installing module – Suman K.C Feb 15 '16 at 9:08
0

To understand this, let's take a look at the extension's XML:

<action ifconfig="amzoom/general/enable" method="unsetChild"><name>product.info.media</name></action>
<block type="amzoom/catalog_product_view_media"  name="product.info.media" as="media">

This removes the old "product.info.media" from the "product.info" block (it still exists, just not in the hierarchy) and then creates a new block with the same name, which replaces the original block.

Your changes have been made to the original block, not to the new one.

This is because the <reference> is resolved during XML merging, before any block is instantiated, and it will merge into the first block that it finds by this name, which is the one that is later removed.

You should know that the layout is generated in two steps:

  1. load and merge all XML. This processes <block>, <reference> and <remove> nodes
  2. build the block hierarchy. This is where block classes are instantiated and <action> nodes are processed.

The only solution that I see, is to change the extension's XML to use a different name for the new block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.