cancel
Showing results for 
Search instead for 
Did you mean: 

Change one attribute delete other

Change one attribute delete other

Hi,
I have this code:

 

$productCollection = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToSelect(array('height', 'width', 'size'));


foreach ($productCollection as $product) {

    $height = $product->getHeight();
    $width = $product->getWidth();

    try {

        $product->setData('size', $height.'x'.$width);
        $product->save();

    } catch (Exception $ex) {
        Mage::log($ex->getMessage(), null, 'size.log', true);
    }

}

Could anyone explain me how this code can delete the price of some products?

 

(price is NULL not 0)


Thanks for any help


UPDATE

I'm starting to ask myself if it's possible that if you don't load all the attributes they are set to NULL.
I expected that Magento only update that fields, but I started to think that he really save all the product again with the information you have, in this case, the two fields I load in the collection and other fields that magento always get like the name and the sku