When you want to filter a collection with custom attribute value it works but when you want to retrieve the non-corresponding entries (like with the neq, null, not null, …. statements) it doesn’t work.
Default join on collection is an inner join so if you are doing that :
1 | $myCollection ()->addAttributeToFilter( 'my_attribute' , array ( 'null' => true)); |
.. you will find no entries
If you want to change the default inner join to a left join you just have to add ‘left’ as the third parameter of the addAttributeToFilter method :
1 | $myCollection ()->addAttributeToFilter( 'my_attribute' , array ( 'null' => true), 'left' ); |
and now it works…
Here is the prototype of the corresponding method in Mage_Catalog_Model_Resource_Product_Collection :
1 | public function addAttributeToFilter( $attribute , $condition = null, $joinType = 'inner' ) |
We can see that inner parameter is used by default