Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $collection->addAttributeToFilter('attributename', array('is' => null));
- $collection->addAttributeToFilter('attributename', array(115,116));
- $collection->addAttributeToFilter(
- array(
- array(
- 'attribute' => 'name_of_attribute_1',
- 'null' => 'this_value_doesnt_matter'
- ),
- array(
- 'attribute' => 'name_of_attribute_2',
- 'in' => array(115, 116)
- )
- )
- );
- var_dump(
- Mage::getModel('catalog/product')
- ->getCollection()
- ->addFieldToFilter(
- array(
- array(
- 'attribute' => 'description',
- 'null' => 'this_value_doesnt_matter'
- ),
- array(
- 'attribute' => 'sku',
- 'in' => array(115, 116)
- )
- )
- )
- ->getSelectSql(true)
- );
- SELECT
- `e`.*,
- IFNULL(_table_description.value, _table_description_default.value) AS `description`
- FROM
- `catalog_product_entity` AS `e`
- INNER JOIN
- `catalog_product_entity_text` AS `_table_description_default` ON
- (_table_description_default.entity_id = e.entity_id) AND
- (_table_description_default.attribute_id='57') AND
- _table_description_default.store_id=0
- LEFT JOIN
- `catalog_product_entity_text` AS `_table_description` ON
- (_table_description.entity_id = e.entity_id) AND
- (_table_description.attribute_id='57') AND
- (_table_description.store_id='1')
- WHERE (
- (IFNULL(_table_description.value, _table_description_default.value) is NULL) OR
- (e.sku in (115, 116))
- )
- $collection->addAttributeToFilter('attribue_name', array('or'=> array(
- 0 => array( 'neq' => '1'),
- 1 => array('is' => new Zend_Db_Expr('null')))
- ), 'left');
- IT's working.
- $collection->addAttributeToFilter(
- array(
- array('attribute' => 'name_of_attribute_1','null' => 'this_value_doesnt_matter'),
- array('attribute' => 'name_of_attribute_2','in' => array(115, 116))
- )
- '',
- 'left'
- );
Add Comment
Please, Sign In to add comment