1

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?

1
  • did you ever solve this? May 24, 2014 at 14:56

2 Answers 2

1

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.

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

This should work.

4
  • I tried to implement it and it didn't work. (Stops the rest of the page from loading) I can see the logic of the code, I'll try to tweak your suggestion and report back if I get it to work. Thanks SR
    – SR_Magento
    Jan 22, 2014 at 14:40
  • I've tried multiple different methods and still no luck.
    – SR_Magento
    Jan 22, 2014 at 17:08
  • I think $_item already is a product. Just try $_item->hasImage()
    – Erfan
    May 24, 2014 at 8:03
  • In hindsight, my method is bad anyway - if you loaded 6 products for a carousel say, and only 4 had images - it would just look weird. You need to modify the collection ideally. May 25, 2014 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.