Pregunta

I am looking for the controller / function which shows the Related Product child html.

On the product view page it is simply called via <?php echo $this->getChildHtml('related'); ?>

I have modified this phtml file to count the related items and show an alternate fallback of a random selection of products by using this:

(Within /catalog/product/list/related.phtml)
<?php if($this->getItems()->getSize() > 1): ?>
Show the products
<?php else: echo $this->getLayout()->createBlock('cms/block')->setBlockId('related-products-fallback')->toHtml(); 
endif;
 ?>

This works perfectly when testing pages with 1 or more related products, but if there are no related products then the Child 'related.phtml' is never called.

I've searched the magento file structure for anything 'related' but can't find the magic file anywhere. I imagine it would be a relative simple if statement somewhere.

¿Fue útil?

Solución

Controller is in app/code/core/Mage/Catalog/Block/Product/List but you should really avoid editing the core directly. Check your block ID and be sure you empty your cache! Flush all cache types and check again!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top