We have round about 1500 products and some of them has no weight, even though it is a required attribute. I think an import in the past was the mistake...
How can i get all products which don't have a weight?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityWe have round about 1500 products and some of them has no weight, even though it is a required attribute. I think an import in the past was the mistake...
How can i get all products which don't have a weight?
For NULL values, not empty ones you can also set condition like
$collection = Mage::getModel('catalog/product')
->getCollection()
->addFieldToFilter('weight', array('null'=>true)
;
Try:
$mageProduct = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect(*)
->addAttributeToFilter('weight'," ");
you can use collection to load all the product having attribute with null value
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('weight', array('eq'=>''),
->addFieldToFilter('other_attribute_code', array('eq'=>''), //Repeat this for more attributes
foreach($collection as $product){
//Do something
$product->getId();
}