在过去的几个小时里,我一直坚持这一点。我通过修改几行代码让它工作了/lib/Varien/Data/Collection/Db.php
,但我宁愿使用正确的解决方案,让我的核心保持不变。
我需要做的就是获取一个集合并按两个或多个字段对其进行过滤。说,customer_firstname
和remote_ip
。这是我的(没有黑客攻击的功能失常Db.php
)代码:
$collection = Mage::getModel('sales/order')->getCollection()->
addAttributeToSelect("*")->
addFieldToFilter(array(array('remote_ip', array('eq'=>'127.0.0.1')),
array('customer_firstname', array('eq'=>'gabe'))), array('eq'=>array(1,2,3)));
用股票Db.php
,我试过这个:(样本取自http://magentoexpert.blogspot.com/2009/12/retrieve-products-with-specific.html)
$collection->addFieldToFilter(array(
array('name'=>'orig_price','eq'=>'Widget A'),
array('name'=>'orig_price','eq'=>'Widget B'),
));
但这给了我这个错误:
Warning: Illegal offset type in isset or empty in magento/lib/Varien/Data/Collection/Db.php on line 369
如果我用 try/catch 包装它,那么它会移动到 _getConditionSql() 并给出这个错误:
Warning: Invalid argument supplied for foreach() in magento/lib/Varien/Data/Collection/Db.php on line 412
有没有人有任何工作的、功能性的代码来做这件事?我正在运行 Magento 1.9(企业版)。谢谢!