Question

The following code is from the related.phtml file and I believe this is what needs to be modified to filter out products without images:

<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>

How do I extend the above code to show products with images only in the related products block?

Was it helpful?

Solution

If you only care about the thumbnail image, which is the one shown in the default template then then try checking if the $_item has that data set.

$_item->hasData('thumbnail')

One note is that currently in the template it only wraps the checkbox with the check that you mentions so you would still display the product even if you add this check, but the user could not add them to the cart.

OTHER TIPS

<?php if(!$_item->isComposite() && $_item->isSaleable() && $_item->getProduct()->hasImage()): ?>

This should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top