2

When setting the product to use the default value, setting the value to false would do it.

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product')
    ->load($product_id)
    ->setStoreId($store_id)
    ->setData($attr, false)
    ->save();

However, it appears that in category, this doesn't work? What am I missing?

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$category = Mage::getModel('catalog/category')
    ->load($category_id)
    ->setStoreId($store_id)
    ->setData($attr, false)
    ->save();

This doesn't work either:

Mage::app()->setCurrentStore(SOME_STORE_ID);
$category = Mage::getModel('catalog/category')->load($category_id);
$category->setAttr(false);
$category->save();
  • Is the attribute on the category locked? Check with $category->isLockedAttribute($attr) – Robbie Averill Jun 1 '16 at 4:18
  • It's not locked, bool(false). – user1240207 Jun 1 '16 at 4:58
0

I was bumping into the same problem as you trying to change the 'display_mode'attribute for a category and when I used isLockedAttribute() I also got false as a result.

However I still went ahead and used $category->unlockAttribute('display_mode') and then $category->setDisplayMode(false) and it saved it correctly.

I still have no idea why it was reporting as unlocked while it was indeed locked but still Robbie's comment was spot on for my case. Maybe it will save someone else the headache if they have to face it like I did anyways.

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.