I’m trying to set category_ids to a product by using following code:
<?php
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($product->getId()),
array("category_ids"=>$this->convertCategories($prod['categories']))
,0
);
?>
Unfortunatly script exits with an exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'attribute_id' in 'where clause'
Some hints? I don’t want to use $product->setCategoryIds()->save() since it’s much more longer in execution.
Thanks in advance.
In the end I’ve had to slightly modify one of magento function and make a workaround:
Thanks bixi for pointing out fact about category_ids, the strange thing is that although it’s not an attribute there is an entry in eav_attribute table called category_ids, and magento is loading attribute model with this code, but crashing when trying to save attribute. Maybe it would be better to remove category_ids attribute at all, so people wouldn’t think that its’ a bug.
About indexes: probably I will need to reindex all data, just in case after using my function, it’s not a big deal since product saving by using
updateAttributeswent from 9sec to 0.75.