1

I need to add a custom nested block to the products.list block for category and search pages. For category, there's no issue unsetting category.products then redefining the block with my custom block included. However, for search, the same approach doesn't appear to work - I get two search.result blocks rendered even after unsetting it. It's highly possibly I'm missing something obvious here but can't see it. My xml definition in local.xml is as follows:

<catalogsearch_result_index>
        <reference name="root">
            <action method="setTemplate"><template>page/category.phtml</template></action>
        </reference>
        <reference name="content">
            <action method="unsetChild">
                <name>search.result</name>
            </action>
            <block type="catalogsearch/result" name="search.result" template="catalogsearch/result.phtml">
                <block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
                    <block type="review_blocks/reviews_product_list" name="reviews" template="reviews/product/list.phtml"/>
                </block>
            </block>
        </reference>
    </catalogsearch_result_index>

Any advice appreciated !

EDIT:

So what I'm doing in the category default layout handle, which works, is as follows:

<catalog_category_default>
        <reference name="content">
            <action method="unsetChild">
                <name>category.products</name>
            </action>
            <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                    <block type="review_blocks/reviews_product_list" name="reviews" template="reviews/product/list.phtml"/>
                </block>
            </block>
        </reference>
    </catalog_category_default>

Within list.phtml, I want to output the reviews for each product via:

<?php echo $this->getChild('reviews')->setProduct($_product)->toHtml() ?>

However, if I try as Marius suggested to do, I can't access my child block and get a fatal error with the above setProduct method :

1

Not an answer to your question, but it might be a solution to your problem.
Why not simply add your child block like this:

<catalogsearch_result_index>
    <reference name="search_result_list">
        <block type="myblock/child_of_product_list" name="myblock" template="block.phtml"/>
    </reference>
</catalogsearch_result_index>
|improve this answer|||||
  • Thanks Marius - tried that but no luck. Updated my post above with more detail. – moncur25 Nov 9 '15 at 15:25
0

It might be that you have more modules which makes updates to your layout and magento makes this bug. You could try to remove the "<layout><updates>" from your catalogsearch etc/config.xml.

|improve this answer|||||

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.