2

I'm using this to update the attributes of a product:

Mage::getSingleton('catalog/product_action')->updateAttributes()

However, I want to set the category IDs as well. But $product->setCategoryIds() is a function not an attribute. Now, it will defeat the purpose of fast product saving if I load the product model just to set the category IDs. Any way I could set the category IDs without loading the product?

1

You can. Just call the product model, assign ID of a product you want to edit, set categories or any other attributes, and save it:

$product = Mage::getModel('catalog/product');
$product->setId(12345);
$product->setCategoryIds(array(3,5,7,11));
$product->save();

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.