【问题标题】:How to filter blank product image from catalogsearch and catalog in magento by observer观察者如何从magento中的目录搜索和目录中过滤空白产品图像
【发布时间】:2015-02-21 06:31:05
【问题描述】:

我需要从目录和目录搜索中过滤 magento 中的空白图像产品。 但它在目录上工作正常。 bt 在目录搜索中不好。

在搜索中搜索产品时出现错误......

  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'));

    }

    }

【问题讨论】:

    标签: magento magento-1.8


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多