【问题标题】:addAttributeToFilter not working in magento 1.4addAttributeToFilter 在 magento 1.4 中不起作用
【发布时间】:2010-07-15 05:19:21
【问题描述】:

我正在使用 addAttributeToFilter 但它检索到错误的结果:

$collection->addAttributeToFilter(array(
        array(
            'attribute' => 'Author_first_name_1',
            'like'        => "%" . 

trim(Mage::helper('catalogsearch')->getQuery()->getQueryText()) . "%",
            ),
        array(
            'attribute' => 'Author_surname_1',
            'like'        => "%" . 

trim(Mage::helper('catalogsearch')->getQuery()->getQueryText()) . "%",
            )
    ));

在这里,我试图获取名字或姓氏与查询字符串匹配的结果,但没有得到正确的结果。如果我从这里删除名字条件,那么它工作正常。谁能帮帮我?

【问题讨论】:

    标签: magento


    【解决方案1】:

    我得到了解决方案...这可能对其他人有帮助。应该是这样的:

    $collection->addAttributeToFilter(array(
                        array('attribute'=>'Author_first_name_1', 
                                'like'=>'%'.Mage::helper('catalogsearch')->getQuery()->getQueryText().'%'
                        ),
                        array('attribute'=>'Author_surname_1', 
                                'like'=>'%'.Mage::helper('catalogsearch')->getQuery()->getQueryText().'%'
                        ),                  
                    ), '', 'left');
    

    快乐编码 海拉尔

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 2013-06-02
      相关资源
      最近更新 更多