The Idea
Since the import that magento has built in is much faster than $product->save()
how about short-circuiting the import process?
The approach
I mean generate an array with 50k (or more) elements in the format that the import needs it. (not sure exactly what that is yet but I tried with one in the code below).
This should be easy enough, specially if you change a bit the script recommended by @SanderMangel.
Then you can insert it directly in the table importexport_importdata
. That is where the data is stored when you press Check file
in the import process.
You can insert it all at once but I think inserting chunks of it would work better.
After the insert is done trigger the import process.
The code
Step 1. Build the array.
$toImport = array();
$totalRows = 50000;
for ($i = 0;$i<$totalRows;$i++) {
$data = array();
$data['store'] = '';
$data['_attribute_set'] = 'Default'; //or any attribute set name
$data['_type'] = 'simple'; //insert only simple products
$data['_product_websites'] = 'base'; //code for the base website
//add some required data for the product like stock, tax class & ...
$data['qty'] = 10;
$data['min_qty'] = 0;
$data['use_config_min_qty'] = 1;
$data['is_qty_decimal'] = 0;
$data['use_config_backorders'] = 1;
$data['min_sale_qty'] = 1;
$data['use_config_min_sale_qty'] = 1;
$data['max_sale_qty'] = 10000;
$data['use_config_max_sale_qty'] = 1;
$data['is_in_stock'] = 1;
$data['notify_stock_qty'] = 0;
$data['use_config_notify_stock_qty'] = 1;
$data['manage_stock'] = 1;
$data['use_config_manage_stock'] = 1;
$data['stock_status_changed_auto'] = 1;
$data['use_config_enable_qty_inc'] = 1;
$data['qty_increments'] = 1;
$data['use_config_qty_increments'] = 1;
$data['enable_qty_increments'] = 0;
$data['is_decimal_divided'] = 0;
$data['tax_class_id'] = 2;
//set the visibility to catalog & search
$data['visibility'] = Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH;
//set status as enabled
$data['status'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
$data['price'] = 9.99; //you can have a function that generates a random price
$data['weight'] = 1.00; //you can have a function that generates a random weight (can use the same as for price even)
//add product specific data
$data['name'] = 'Some name'. $i; //you can generate a random string
$data['sku'] = 'some sku'.$i; //you can generate a random SKU
$data['description'] = 'Some description'.$i; //you can generated a random description
$data['short_description'] = 'Some short description'.$i; //you can generated a random short description
//continue with all the other required attributes if you have any
//add categories
$data['_category'] = '...';//not sure how this should look like
//add images if needed. The images must be placed in `media/import`
$data['image'] = '/path/to/image.png';
$data['small_image'] = '/path/to/image.png';
$data['thumbnail'] = '/path/to/image.png';
$toImport[] = $data; //add the row to the import data
}
Step 2. Insert the array in the importexport_importdata
table
//get an instance of the import model
$importModel = Mage::getResourceSingleton('importexport/import_data');
//clear all data that is already in the table for import
$importModel->cleanBunches();
//add your new data for import. `$toImport` is the array from step 1.
//you can even split the `$toImport` array into pieces of 2000 or something like that using `array_chunk`
$importModel->saveBunch('catalog_product', 'append', $toImport);
Step 3. Trigger the import script
Mage::getModel('importexport/import')->importSource();
I've used a similar script for an import and it seams to work, but I haven't used it on a live environment yet.
The conclusion
I'm not sure this will work for 50K products but it seams like a good place to start.
A reindex may be required when the import is done. Here you may hit an other problem. Indexing 50k products is not that fast.