I have csv flat file with the items and with the category and subcategories attached to this item. Using this file i have to create a categories tree. I have this piece of code:
there is a loop here and some code to get data from file line by line{
$category = Mage::getModel('catalog/category');
$category->setName($level);
$category->setUrlKey(strtolower($level));
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(1);
$category->setStoreId(1);
$category->setPath($parent_path);
$category->save();
}
and generally it works fine but because of save()
method in loop it takes ages... how could I optimize it? I tried to move save()
outside the loop but it doesn't work also saveAttribute()
method doesn't work.