Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [...] WHERE
- (
- attribute_1 LIKE '%foo%'
- AND
- attribute_2 LIKE '%bar%'
- )
- OR
- (
- attribute_1 LIKE '%foo%'
- AND
- attribute_2 is NULL
- )
- $categories = Mage::getModel('catalog/category')
- ->getCollection()
- ->addAttributeToSelect('*')
- ->addAttributeToFilter(
- array(
- array(
- array(
- 'attribute' => 'attribute_1',
- 'like' => '%foo%'
- ),
- array(
- 'attribute' => 'attribute_2',
- 'like' => '%bar%'
- ),
- ),
- array(
- array(
- 'attribute' => 'attribute_1',
- 'like' => '%foo%'
- ),
- array(
- 'attribute' => 'attribute_2',
- 'null' => true
- ),
- ),
- )
- );
- (
- attribute_1 LIKE '%foo%'
- AND
- attribute_2 LIKE '%bar%'
- )
- OR
- (
- attribute_1 LIKE '%foo%'
- AND
- attribute_2 is NULL
- )
- attribute_1 LIKE '%foo%'
- AND
- (
- attribute_2 LIKE '%bar%'
- OR
- attribute_2 is NULL
- )
- $collection->addAttributeToFilter('attribute_1', ['like' => '%foo%']);
- $collection->addAttributeToFilter('attribute_2', [['like' => '%bar%'], ['null' => true]]);
- $collection->getSelect()->where(
- "(attribute_1 LIKE '%foo%' AND attribute_2 LIKE '%bar%') OR
- attribute_1 LIKE '%baz%' AND attribute_2 is NULL"
- );
- WHERE (...)
- AND
- (
- (
- attribute_1 LIKE '%foo%'
- AND
- attribute_2 LIKE '%bar%'
- ) OR (
- attribute_1 LIKE '%baz%'
- AND
- attribute_2 is NULL
- )
- )
Add Comment
Please, Sign In to add comment