Magento : Filter Collection by Attribute that Doesn't Exist or Null or another condition
After some tests, the code I wrote in the third edit of the question seems to work fine, so I think it is the correct answer:
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect(array('sku', 'name', 'newfield'))
->addAttributeToFilter(
array(
array('attribute'=> 'newfield','null' => true),
array('attribute'=> 'newfield','eq' => ''),
array('attribute'=> 'newfield','eq' => 'NO FIELD')
),
'',
'left');
I checked it and it returns me the products where the newfield is not set yet, and the products where newfield is NULL, string(0) or string(8) "NO FIELD".
PD: if only need one condition and do not need the OR, then it is enough with:
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect(array('sku', 'name', 'newfield'))
->addAttributeToFilter('newfield', array('null' => true), 'left');