0

I wanted to add a FAQ tab to the products page. I created an attribute called faq in the admin panel as textarea with wysiwyg. I also gave it a default value. Then I added the attribute to an attribute set so it showed up in the product configuration in the backend and added some text. Finally I added this to the catalog.xml in my own templates folder (based on rwd).

<block type="catalog/product_view_attributes" name="faq" as="additional" template="catalog/product/view/attributes.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>FAQ</value></action>
</block>

Now the Tab shows up in the frontend but neither shows my default value for the attribute nor the text I added in the product configuration.

Instead it shows for some products an exact copy of the description tab or for other products some additional fields like weight, etc.

Any idea what I am doing wrong here?

  • Is your attribute code faq? – harri Jun 8 '18 at 11:55
0

Your code seems correct and as others have suggested for Magento 1:

Layout

<?xml version="1.0"?>
<layout>
<catalog_product_view>
    <reference name="product.info">
        <block type="catalog/product_view_attributes" name="faq" template="catalog/product/view/attributes.phtml">
            <action method="addToParentGroup"><group>detailed_info</group></action>
            <action method="setTitle" translate="value"><value>FAQ</value></action>
        </block>
    </reference>
</catalog_product_view>
</layout>

app/frontend/design/{packageName}/{themeName}/layout/local.xml

Your attribute for FAQ must have the attribute code faq for the above to work but just update this within name to your attribute value.

Adding Custom Tabs in Product Detail Page

  • Thanks for your answer. Unfortunately this didn't work for me but instead had the effect that the detailed_info group and everything below that disappeared from the page. I am using Magento 1.9.3, maybe I should have added that. Is your solution for Magento2? Or maybe I just did something wrong. Anyways I was able to solve this problem myself by changing my own code above to use a new template and creating that (which i basically copied over from the description template and edited to use the faq attribute instead of description) – Chaz Jun 8 '18 at 11:50
  • Ah sorry this was for Magento 2 – harri Jun 8 '18 at 11:52
  • This looks pretty much like how I did it now, so I'll just accept it as an answer, thank you very much! Only thing: I didn't test it with the attributes.phtml template but instead created a new template: faq.phtml which like I said I just copied from the description.phtml template just editing this to show my faq attribute instead of description – Chaz Jun 8 '18 at 12:07
  • Yeah it was im not sure what was wrong but glad you have sorted it nice one! – harri Jun 8 '18 at 12:09

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.