Vote count:
0
I am a newbie in magento. Basically I want to assign multiple products to multiple categories and I have done the Following code which is working fine :
$collection = Mage::getModel('catalog/product')->getCollection();//my coustom collection
$categorys_ids = array(1,2,3,4,5);//Array of ids etc
if ($categorys_ids != NULL && $collection->getData()!= NULL)
{
foreach ($collection as $product)
{
$categories_pd = $product->getCategoryIds();
$product->setCategoryIds(array_merge($product->getCategoryIds(),array($categorys_ids)));
$product->save();
}
}
Now the main issue is that when I assign set catgeory id for the products it takes a lot of time. I have 200 products and this takes upto two minutes or so.. which is alote of time.
I was wondering if there is a way that I can assign categories to products array instead of assigning products to categories or some thing that can be optimized and take less time.
Thanks guys any help is appricated :)
asked 2 mins ago
Aucun commentaire:
Enregistrer un commentaire