Guest User

Untitled

a guest
Jan 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. $collection->addAttributeToFilter('attributename', array('is' => null));
  2. $collection->addAttributeToFilter('attributename', array(115,116));
  3.  
  4. $collection->addAttributeToFilter(
  5. array(
  6. array(
  7. 'attribute' => 'name_of_attribute_1',
  8. 'null' => 'this_value_doesnt_matter'
  9. ),
  10. array(
  11. 'attribute' => 'name_of_attribute_2',
  12. 'in' => array(115, 116)
  13. )
  14. )
  15. );
  16.  
  17. var_dump(
  18. Mage::getModel('catalog/product')
  19. ->getCollection()
  20. ->addFieldToFilter(
  21. array(
  22. array(
  23. 'attribute' => 'description',
  24. 'null' => 'this_value_doesnt_matter'
  25. ),
  26. array(
  27. 'attribute' => 'sku',
  28. 'in' => array(115, 116)
  29. )
  30. )
  31. )
  32. ->getSelectSql(true)
  33. );
  34.  
  35. SELECT
  36. `e`.*,
  37. IFNULL(_table_description.value, _table_description_default.value) AS `description`
  38. FROM
  39. `catalog_product_entity` AS `e`
  40. INNER JOIN
  41. `catalog_product_entity_text` AS `_table_description_default` ON
  42. (_table_description_default.entity_id = e.entity_id) AND
  43. (_table_description_default.attribute_id='57') AND
  44. _table_description_default.store_id=0
  45. LEFT JOIN
  46. `catalog_product_entity_text` AS `_table_description` ON
  47. (_table_description.entity_id = e.entity_id) AND
  48. (_table_description.attribute_id='57') AND
  49. (_table_description.store_id='1')
  50. WHERE (
  51. (IFNULL(_table_description.value, _table_description_default.value) is NULL) OR
  52. (e.sku in (115, 116))
  53. )
  54.  
  55. $collection->addAttributeToFilter('attribue_name', array('or'=> array(
  56. 0 => array( 'neq' => '1'),
  57. 1 => array('is' => new Zend_Db_Expr('null')))
  58. ), 'left');
  59. IT's working.
  60.  
  61. $collection->addAttributeToFilter(
  62. array(
  63. array('attribute' => 'name_of_attribute_1','null' => 'this_value_doesnt_matter'),
  64. array('attribute' => 'name_of_attribute_2','in' => array(115, 116))
  65. )
  66. '',
  67. 'left'
  68. );
Add Comment
Please, Sign In to add comment