0

I'm trying to add a new products block to the product view pages, I have several products marked as new & they DO show up on the homepage, for some reason they won't display on the individual product pages.

here is what I have in my local.xml

<catalog_product_view>

        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>

        <reference name="content">

        <block type="catalog/product_new" name="product_list_popular" alias="product_list_popular" template="catalog/product/product_list_popular.phtml">
            <action method="addPriceBlockType">
                <type>bundle</type>
                <block>bundle/catalog_product_price</block>
                <template>bundle/catalog/product/price.phtml</template>
            </action>
            <action method="setProductsCount"><count>8</count></action>
        </block>

        </reference>


    </catalog_product_view>

I have tried this in the content reference and by adding

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

to the 1column template [and removing the reference from local.xml] - niether of these work.

what am I doing wrong?

  • If you are called child html then must be required parent block but your content not parent block – Abdul Nov 3 '15 at 4:30
  • can you please tell me which location add <?php echo $this->getChildHtml('product_list_popular') ?> function ? – Abdul Nov 3 '15 at 4:31
1

try do some thing like this

in your xml add code

<catalog_product_view>
    <reference name="root">
        <action method="setTemplate">
            <template>page/1column.phtml</template>
        </action>
    </reference>
    <reference name="product.info">
        <block type="catalog/product_new" name="product_list_popular" alias="product_list_popular" template="catalog/product/product_list_popular.phtml">
            <action method="addPriceBlockType">
                <type>bundle</type>
                <block>bundle/catalog_product_price</block>
                <template>bundle/catalog/product/price.phtml</template>
            </action>
            <action method="setProductsCount">
                <count>8</count>
            </action>
        </block>
    </reference>
</catalog_product_view>

And in your catalog/product/view.phtml file call child html

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

I assume,you have trying to call product_list_popular call at view.phtml and as per as magento default behavior

catalog/product/view.phtml template's layout alias name is product.info.

As getChildHtml() only work whenever product_list_popular is child block of product.info.

and call <?php echo $this->getChildHtml('product_list_popular') ?> at view.phtml.

You need to understand the getChildHtml() concept at magento.

For you requirement,you need to change
<reference name="content">

to

<reference name="product.info"> 

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.