我想制作看起来像这样的过滤器:
(伪代码)
SELECT * FROM Products WHERE
(`attribute_foo` LIKE 'bar' AND `attribute_bar` LIKE 'foo')
OR (`attribute_far` LIKE 'boo');
我知道如何通过提供数组来构造OR
条件,而不是两者。
谢谢你
答案 0 :(得分:2)
"from"=>$fromValue, "to"=>$toValue
"like"=>$likeValue
"neq"=>$notEqualValue
"in"=>array($inValues)
"nin"=>array($notInValues)
"eq"=>$equal
"nlike"=>$notlike
"is"=>$is
"gt"=>$greaterthan
"lt"=>$lessthan
"gteq"=>$greterthanequal
"lteq"=>$lessthanequal
"finset"=>$unknown
"date"=>true, "to" => $now
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->addFieldToFilter('entity_id', array('from'=>20, 'to'=>30))
->addFieldToFilter('name', array('like'=>'%cindy%'));
答案 1 :(得分:0)
您可以使用Magento数据对象进行过滤:
$product = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter("attribute_code", $value);
print_r($product->getItems());