Answer
In Magento we can use addAttributeToFilter Conditions same as WHERE in SQL
Below are the all condtions
Equals: eq
$_products
->addAttributeToFilter(
\'status\'
,
array
(
\'eq\'
=> 1));
Not Equals - neq
$_products
->addAttributeToFilter(
\'sku\'
,
array
(
\'neq\'
=>
\'test-product\'
));
Like - like
$_products
->addAttributeToFilter(
\'sku\'
,
array
(
\'like\'
=>
\'UX%\'
));
One thing to note about like is that you can include SQL wildcard characters such as the percent sign.
Not Like - nlike
$_products
->addAttributeToFilter(
\'sku\'
,
array
(
\'nlike\'
=>
\'err-prod%\'
));
In - in
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'in\'
=>
array
(1,4,98)));
When using in, the value parameter accepts an array of values.
Not In - nin
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'nin\'
=>
array
(1,4,98)));
NULL - null
$_products
->addAttributeToFilter(
\'description\'
,
\'null\'
);
Not NULL - notnull
1
$_products
->addAttributeToFilter(
\'description\'
,
\'notnull\'
);
Greater Than - gt
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'gt\'
=> 5));
Less Than - lt
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'lt\'
=> 5));
Greater Than or Equals To- gteq
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'gteq\'
=> 5));
Less Than or Equals To - lteq
$_products
->addAttributeToFilter(
\'id\'
,
array
(
\'lteq\'
=> 5));
All magento Questions
Ask your interview questions on magento
Write Your comment or Questions if you want the answers on magento from magento Experts