Magento add product info to More Info tab

2019-08-04 03:15发布

问题:

I am trying to show Magento product stock information and Magento product price information in the tab Description.

I have copied the following code from: app/design/frontend/default/theme/template/catalog/product/view.phtml

<?php echo $this->getChildHtml('product_type_data') ?>

into: app/design/frontend/default/theme/template/catalog/product/view/description.phtml

This displays the stock and price information on view.phtml, but nothing is shown in description.phtml.

Any suggestion?

回答1:

The problem is that product_type_data block is a child of product.info (from where you actually copied it) and not description block.

So what do you have to do is to add the following code to local.xml file of your theme:

<PRODUCT_TYPE_simple>
    <reference name="product.description">
        <block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="catalog/product/view/type/default.phtml">
            <block type="core/text_list" name="product.info.simple.extra" as="product_type_data_extra" translate="label">
                <label>Product Extra Info</label>
            </block>
        </block>
    </reference>
</PRODUCT_TYPE_simple>
<PRODUCT_TYPE_configurable>
    <reference name="product.description">
        <block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml">
            <block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label">
                <label>Product Extra Info</label>
            </block>
        </block>
    </reference>
</PRODUCT_TYPE_configurable>
<PRODUCT_TYPE_grouped>
    <reference name="product.description">
        <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml">
            <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label">
                <label>Product Extra Info</label>
            </block>
        </block>
    </reference>
</PRODUCT_TYPE_grouped>
<PRODUCT_TYPE_virtual>
    <reference name="product.description">
        <block type="catalog/product_view_type_virtual" name="product.info.virtual" as="product_type_data" template="catalog/product/view/type/default.phtml">
            <block type="core/text_list" name="product.info.virtual.extra" as="product_type_data_extra" translate="label">
                <label>Product Extra Info</label>
            </block>
        </block>
    </reference>
</PRODUCT_TYPE_virtual>