Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://magento.stackexchange.com/questions/7908/multi-conditionals-or-and-and-inside-and-in-addattributetofilter
- //Using AND and OR condition with addAttributeToFilter
- $collection
- //AND Condition
- ->addAttributeToFilter('special_price', array('gt' => 0))
- ->addAttributeToFilter('special_from_date', array('lteq' =>date('Y-m-d')))
- //OR Condition
- ->addAttributeToFilter(array(
- array(
- 'attribute' => 'special_to_date',
- 'gteq' => date('Y-m-d'),
- ),
- array(
- 'attribute' => 'special_to_date',
- 'null' => true,
- )
- ));
- //$collection->getSelect() with condition
- $collection->getSelect()
- ->where("((`e`.`special_from_date` < '".date('Y-m-d')."') OR (`e`.`special_to_date` > '".date('Y-m-d')."')) OR ((`e`.`news_from_date` IS NULL) OR (`e`.`news_to_date` IS NULL))");
- //Add filters using addAttributeToFilter Conditionals
- //http://php.quicoto.com/add-filters-using-addattributetofilter-conditionals-magento/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement