如何通过观察者从magento中的catalogsearch和catalog中过滤空白产品图像

时间:2014-12-23 05:55:53

标签: magento magento-1.8

我需要从目录和catalogsearch中过滤magento中的空白图像产品。 但它在目录上运行良好。在目录搜索中不行。

我在搜索中搜索产品时遇到错误....

  Column not found: 1054 Unknown column 'e.small_image' in 'where clause'"

我的观察者config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Nine_Catalog>
            <version>1.0.0</version>
        </Nine_Catalog>
    </modules>
    <global>
        <events>
            <catalog_block_product_list_collection>
                <observers>
                    <filter_blank_image> // unique idrntifer
                     <type>model</type>
                        <class>Nine_Catalog_Model_Observer</class>
                        <method>filterBlankImage</method>
                    </filter_blank_image>
                </observers>
            </catalog_block_product_list_collection>
        </events>
        </global>
</config>


my observer
------------------
 class Nine_Catalog_Model_Observer extends Varien_Event_Observer{

    public function filterBlankImage(Varien_Event_Observer $observer)
    {

        $collection = $observer->getEvent()->getCollection();

       return  $collection->addAttributeToFilter('small_image',array('neq'=>'no_selection'));

    }

    }

1 个答案:

答案 0 :(得分:0)

您需要将属性更改为“在产品列表中使用”为“是”,以便在平面集合中使用它。