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?

        $product = Mage::getModel('catalog/product');
        $product->setAttributeSetId($attributeSetId);//ID of a attribute set named 'default'
        $product->setTypeId('simple');  //product type
        $product->setSku($itemjson->getSku($i)); //SKU
        $product->setName($itemjson->getName($i)); //product name
        $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->setShortDescription($itemjson->getShortDesc($i)) ;
               '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
        $product = self::manageAttr($product,$catArray);
  • why are you not using the loop here?
    – Saurabh
    Commented May 20, 2015 at 18:06
  • 1
    There is no builk product creation. Use a loop. If you want to buil-update certain attributes, that is possible: stackoverflow.com/questions/10355652/…
    – laketuna
    Commented May 20, 2015 at 19:36
  • Yes I tried looping here, but performance getting badly hit, If I loop around it, Only one item per second is getting saved, can anyone atleast help me how increase the performance Commented May 21, 2015 at 4:30

3 Answers 3


maybe this instruction helps you.


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


I think a real good way to go if you want quick bulk-inserting products is this free plugin ApiImport:

It requires some programming skills, but in the end you'll be rocketing those product into your DB.

Combine with this URL INDEX MODULE from EcomDev (Also compatible with 1.7 - 1.9.2+) and reindexing is much quicker after an import.

Easy does it! ;)

This is how your code would look like:

require_once 'app/Mage.php';

$out = array();

$attributes = array(
    'desc' => 'description',
    'stock' => 'qty'
); // all the items you want to update

for($x->whatever_place_you_get_your_data_from() as $i)
    echo "$i\r";

    foreach($attr as $json_key => $attr)
            case 'website_ids':
            case 'status':
                $out[$i][$attr] = 1;
            case 'qty':
            case 'description':
                $out[$i][$attr] = $itemjson->{'get'.ucfirst($json_key)}($i);
            case 'name':
            case 'sku':
            case 'weight':
                $out[$i][$attr] = $itemjson->{'get'.ucfirst($attr)}($i);
            // etc...


$api = Mage::getModel('api_import/import_api');

You can check this script magento_dummy_simple_products_generation.php

Basically it allows you to create a bulk set of simple products, you hard code the PRODUCT_QTY to set the desired number of generated simple products (by default 15) and the CATEGORY_ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.