0

So, I updated the "product_length" label attribute and now I can't save a new product value to this attribute. I can't save this value by admin or programatically.

$_product = Mage::getModel('catalog/product')->load(12448);
$_product->getData('product_length'); // '195'
$_product->setData('product_length', '29');
$_product->save();
//
$_product = Mage::getModel('catalog/product')->load(12448);
$_product->getData('product_length'); // '195'

New products (that are created after the attribute update) works fine.

I already tried reindex all, disable and enable flat tables, clear cache (redis and files) and nothing works. There's nothing in exception.log or system.log.

Somebody help me, please! =)

1

You can use following code

$product = Mage::getModel('catalog/product')->load(1);
$product->setName('foobar!');
try {
   $product->save();
} catch(Exception $e) {
  echo "{$e}";
}

it will display error if there any error.

Your you can use this it's works for me

$product=Mage::getModel('catalog/product')->load($id);
$product->setSpecialFromDate('2010-10-28');
// below code use for time format 
$product->getResource()->saveAttribute($product, 'special_from_date');
| improve this answer | |
0

I find the solution!!

When I updated the attribute's label via admin, the 'backend_type' at 'eav_attribute' mysql table changed from 'int' to 'varchar'. So I executed the query:

UPDATE `eav_attribute` SET `backend_type` = 'int' WHERE `eav_attribute`.`attribute_id` = 177;

and solves the problem.

I hope this can help you too.

| improve this answer | |

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.