1

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?

5

For NULL values, not empty ones you can also set condition like

 $collection = Mage::getModel('catalog/product')
        ->getCollection()
        ->addFieldToFilter('weight', array('null'=>true)
 ;
0

Try:

$mageProduct = Mage::getModel('catalog/product')
        ->getCollection()
        ->addAttributeToSelect(*)
        ->addAttributeToFilter('weight'," ");
0

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();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.