$category_id = 8711;
$cat = Mage::getModel("catalog/category")->load($category_id);
$cat->setData('is_active', 0);

it does not work...



Your code is okay, but if it's a standalone script that just uses Mage::app(); at the beginning, it will not work, but it does if you set a store ID via setCurrentStore(store_id)

To change the default value, you can use

# your code here
  • it worked: Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
    – Majör
    Oct 11 '17 at 6:38
  • @Majör this load(...) isnt necessary. setCurrentStoreId(...) should be enough (at least it worked for me). Please accept, answer if it solved your problem.
    – sv3n
    Oct 11 '17 at 8:47

I recon your code should work but if it does not, try this:

$category_id = 8711;
$cat = Mage::getModel("catalog/category")->load($category_id);

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.