Magento addFieldToFilter: Two fields, match as OR, not AND

后端 未结 10 1224
孤街浪徒
孤街浪徒 2020-12-04 09:42

I\'ve been stuck on this for the last few hours. I got it working by hacking a few lines in /lib/Varien/Data/Collection/Db.php, but I\'d rather use the proper s

10条回答
  •  攒了一身酷
    2020-12-04 10:17

    This is the real magento way:

        $collection=Mage::getModel('sales/order')
                    ->getCollection()
                    ->addFieldToFilter(
                            array(
                                'customer_firstname',//attribute_1 with key 0
                                'remote_ip',//attribute_2 with key 1
                            ),
                            array(
                                array('eq'=>'gabe'),//condition for attribute_1 with key 0
                                array('eq'=>'127.0.0.1'),//condition for attribute_2
                                    )
                                )
                            );
    

提交回复
热议问题