Magento – How to create/update bulk of products at a time programmatically

ce-1.9.0.1magento-1.9programmaticallysimple-product

In the following code I have written to create a single simple product at a time, but I want to make a bulk creation of products at a time, can anyone help me in doing this?

Mage::app('default')->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
        $product = Mage::getModel('catalog/product');
        $product->setAttributeSetId($attributeSetId);//ID of a attribute set named 'default'
        $product->setTypeId('simple');  //product type
        $product->setWebsiteIds(array(1));
        $product->setSku($itemjson->getSku($i)); //SKU
        $product->setName($itemjson->getName($i)); //product name
        $product->setWeight($itemjson->getWeight($i));
        $product->setUpdatedAt(strtotime('now'));
        $product->setStatus(1);//product status (1 - enabled, 2 - disabled)
        $product->setTaxClassId(4); //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
        $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); //catalog and search visibility
        $product->setPrice($price); //price in form 11.22
        $product->setDescription($itemjson->getDesc($i));
        $product->setShortDescription($itemjson->getShortDesc($i)) ;
        $product->setStockData(array(
               'use_config_manage_stock' => 0, //'Use config settings' checkbox
               'manage_stock'=>1, //manage stock
               'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
               'max_sale_qty'=>1000, //Maximum Qty Allowed in Shopping Cart
               'is_in_stock' => 1, //Stock Availability
               'qty' => $itemjson->getStock($i), //qty
                )
            );
        $catArray=$itemjson->getSimpleCat($i);
        $catKeys=array_keys($catArray);
        $product = self::manageAttr($product,$catArray);
        $product->setCategoryIds($categories);
        $product->save();
        

Best Answer

maybe this instruction helps you.

$product->setIsMassupdate(true)->setExcludeUrlRewrite(true);

This may say Magento that is not necessary reindex tables on each product save.