隐藏没有图像的产品magento [英] Hide Products without images magento

查看:44
本文介绍了隐藏没有图像的产品magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了此答案,以隐藏类别列表页面上没有图像的产品.它工作了好一阵子.

I have followed this answer to hide products without images on the category listing page. It worked nicely for a while.

现在,由于某种原因,似乎没有图像的产品仍在列表页面上显示.关于为什么可能会发生这种情况的任何想法?

Now, for some reason it seems the products without images are still showing up on the listing page. Any ideas as to why this may be happening?

注意:使用了相同的list.phtml页面.

Note: The same list.phtml page is being used.

谢谢.

推荐答案

将以下内容添加到list.phtm:

Add the following to list.phtm:

//$_productCollection=$this->getLoadedProductCollection();
$_productCollection = clone $this->getLoadedProductCollection();
$_productCollection->clear()
                   ->addAttributeToFilter('small_image', array('neq' => 'no_selection'))
                   ->load();

此答案建议以下内容:

->addAttributeToFilter('image', array('neq' => 'no_selection'))

我将其设置为:

->addAttributeToFilter('small_image', array('neq' => 'no_selection'))

上一个答案不起作用的原因是因为产品集合未加载常规图像,因此常规图像无法添加为要过滤的属性,因此,我添加了small_image作为要过滤的属性

The reason the previous answer did not work was because the product collection doesn't load the regular image, and therefore the regular image cannot be added as an attribute to filter, so instead, I added the small_image as the attribute to filter.

您还可以尝试 RS的答案,他将图像添加到页面中,从而添加图像.您可能还必须使用以下命令添加所有属性:

You can also try R.S's answer where he adds the image to the page and hence the collection. You may have to also add all attributes using:

->addAttributeToSelect('*')

这篇关于隐藏没有图像的产品magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆