1

I'm trying to add a new block to the Product View page using my local.xml file, within this file I have the following:

<catalog_product_view translate="label">
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <block type="underlay_products/carpets" name="catalog.product.carpet_underlay" as="carpet_underlay" template="catalog/product/views/partials/carpet_underlay.phtml"/>
        </block>
    </reference>
</catalog_product_view>

Which adds the block, but it's in the wrong place and duplicates the product view page (there's 2 images, 2 product names, etc) and my block is at the bottom when it should be in a different place.

However, if I add this line to my catalog.xml file underneath the related_products block it works absolutely fine, the content is in the right place and there's no duplication of the product:

 <block type="underlay_products/carpets" name="catalog.product.carpet_underlay" as="carpet_underlay" template="catalog/product/views/partials/carpet_underlay.phtml"/>

Any ideas why this happens and I can use my local.xml file instead?

1

The reason you have the catalog view twice is because you wrap your code with the following.

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

What you can do is call reference to use the current block.

<reference name="product.info">
     <block type="underlay_products/carpets" name="catalog.product.carpet_underlay" as="carpet_underlay" template="catalog/product/views/partials/carpet_underlay.phtml"/>
</reference>
1
  • Oh bloody hell, you're right. Rather than using reference in my local.xml I was still trying to use block. Thanks a lot!
    – Karl
    Mar 26 '15 at 14:25
1

There is no need for re-defining

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

in local.xml, All you need is to add your block to existing block. Below should work ( I have not tested though )

<catalog_product_view translate="label">
  <reference name="product.info">
       <block type="underlay_products/carpets" name="catalog.product.carpet_underlay" as="carpet_underlay" template="catalog/product/views/partials/carpet_underlay.phtml"/>
  </reference> 
</catalog_product_view>

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.