How to addAttributeToFilter AND and OR at the same time?
I'd like to make filter which looks like this :
(pseudo code)SELECT * FROM Products WHERE
(`attribute_foo` LIKE 'bar' AND `attribute_bar` LIKE 'foo')
OR 开发者_JS百科(`attribute_far` LIKE 'boo');
I know how to construct OR
condition by providing an array, but not the both.
thanks you
"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%'));
You can use Magento data object to filter:
$product = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter("attribute_code", $value);
print_r($product->getItems());
精彩评论