Magento provide addAttributeToFilter to use and operator in $collection, But using of OR operator is little bit different . I was guess that there must be and OrAttributeToFilter , But I was wrong I think magento forgot to write this function, Lastly I found the solution to use mysql OR in magento . In addAttributeToFilter we have to write the condition in the form of array.
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter(
array(
array('attribute'=>'category_ids','finset'=>2),
array('attribute'=>'category_ids','finset'=>3)
)
);
}
use your own attribute name and value to get the data
No comments:
Post a Comment