├── .gitignore ├── composer.json ├── create.php ├── README.md └── seed.csv /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | vendor 3 | composer.lock 4 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "joshribakoff/magento-sample-products", 3 | "require": { 4 | "joshribakoff/php-csv-utils":"*", 5 | "corneltek/getoptionkit": "~1.2" 6 | } 7 | } -------------------------------------------------------------------------------- /create.php: -------------------------------------------------------------------------------- 1 | add( 'n|number:=i' , 'option requires a integer value' ); 8 | 9 | try { 10 | $result = $getopt->parse( $argv ); 11 | $number = $result->number ? $result->number:10; 12 | } catch(Exception $e) { 13 | echo 'Try: create.php --number=10'; 14 | exit; 15 | } 16 | 17 | $seedFile = 'seed.csv'; 18 | $reader = new Csv_Reader($seedFile, new Csv_Dialect()); 19 | $headerRow = $reader->getAssociativeRow(); 20 | $seedRow = $reader->getAssociativeRow(); 21 | $writer = new Csv_Writer(STDOUT, new Csv_Dialect(array( 22 | 'quoting' => Csv_Dialect::QUOTE_ALL 23 | ))); 24 | $writer->writeRow($headerRow); 25 | for($i=1; $i<=$number; $i++) { 26 | $productRow = array_merge($seedRow, array( 27 | 'sku' => 'sku-'.$i, 28 | 'name' => 'product '.$i, 29 | )); 30 | $writer->writeRow($productRow); 31 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Intro 2 | ======================= 3 | 4 | I had a need to create 100s or even 1,000s of Magento products for debugging purposes. This tool creates X number of products "product 1", "product 2", etc.. for the SKU/name for Magento testing purposes. Actually it creates a CSV full of sample products for importing into Magento. 5 | 6 | Usage 7 | ===== 8 | Call it on the command line as you would expect: 9 | 10 | ``` 11 | php create.php 12 | ``` 13 | 14 | It will write the output CSV to stdout, so feel free to pipe that to a file 15 | ``` 16 | php create.php > out.csv 17 | ``` 18 | 19 | You can then call Magento's import on that file to import the sample products into your Magento store. 20 | 21 | 22 | You can specify the number of sample products to create 23 | ``` 24 | php create.php --number=100 > out.csv 25 | ``` 26 | 27 | It will use the default pricing/values from the seed.csv, except for SKU & name which are set to "skuN" and "product N" respectively, where N is an increasing number. 28 | 29 | Importing 30 | ========= 31 | 32 | Magento's import/export is.... let's just say "less than desirable". I ran into bugs like categories not being assigned, and its slow as shit. There's a 3rd party tool which does a wonderful job - https://github.com/dweeves/magmi-git 33 | -------------------------------------------------------------------------------- /seed.csv: -------------------------------------------------------------------------------- 1 | "store","websites","attribute_set","type","category_ids","sku","has_options","name","meta_title","meta_description","image","small_image","thumbnail","url_key","url_path","custom_design","page_layout","options_container","country_of_manufacture","msrp_enabled","msrp_display_actual_price_type","gift_message_available","price","special_price","weight","msrp","status","is_recurring","visibility","enable_googlecheckout","tax_class_id","description","short_description","meta_keyword","custom_layout_update","special_from_date","special_to_date","news_from_date","news_to_date","custom_design_from","custom_design_to","qty","min_qty","use_config_min_qty","is_qty_decimal","backorders","use_config_backorders","min_sale_qty","use_config_min_sale_qty","max_sale_qty","use_config_max_sale_qty","is_in_stock","low_stock_date","notify_stock_qty","use_config_notify_stock_qty","manage_stock","use_config_manage_stock","stock_status_changed_auto","use_config_qty_increments","qty_increments","use_config_enable_qty_inc","enable_qty_increments","is_decimal_divided","stock_status_changed_automatically","use_config_enable_qty_increments","product_name","store_id","product_type_id","product_status_changed","product_changed_websites","color" 2 | "admin","base","Default","simple","2","114-9550-4","0","test","","","","","","test","test.html","","No layout updates","Block after Info Column"," ","Use config","Use config","No","1.0000","","1.0000","","Enabled","No","Catalog, Search","Yes","None","test","test","","","","","","","","","555.0000","0.0000","1","0","0","1","1.0000","1","0.0000","1","1","","","1","0","1","0","1","0.0000","1","0","0","0","1","test","0","simple","","","" --------------------------------------------------------------------------------