Last active
February 15, 2017 14:56
-
-
Save yaronish/3f03dab461c9c44ee8f5006ce2a29c12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $file = 'bundle.csv'; | |
| $columns = [ | |
| 'sku', 'name', 'store_view_code', 'attribute_set_code', 'product_type', 'categories', 'product_websites', | |
| 'bundle_price_type', 'bundle_sku_type', 'bundle_price_view', 'bundle_weight_type', 'bundle_values', 'bundle_shipment_type' | |
| ]; | |
| $productsNumber = 30; | |
| $optionsNumber = 5; | |
| $itemsInOption = 100; | |
| $data = []; | |
| for ($k = 1; $k <= $productsNumber; $k++) { | |
| $optionPattern = 'name=Option %s,type=select,required=1,sku=Configurable Product %s-option%s,price=0.0000,default=0,default_qty=1.0000,price_type=fixed'; | |
| $options = []; | |
| for ($i = 1; $i <= $optionsNumber; $i++) { | |
| for ($j = 1; $j <= $itemsInOption; $j++) { | |
| $options[] = sprintf( | |
| $optionPattern, | |
| $i, $i, $j | |
| ); | |
| } | |
| } | |
| $data[] = [ | |
| 'sku' => 'bundle-' . $k, | |
| 'name' => 'Bundle ' . $k, | |
| 'store_view_code' => '', | |
| 'attribute_set_code' => 'Default', | |
| 'product_type' => 'bundle', | |
| 'categories' => 'Default Category/Category 2', | |
| 'product_websites' => 'base', | |
| 'bundle_price_type' => 'dynamic', | |
| 'bundle_sku_type' => 'dynamic', | |
| 'bundle_price_view' => 'Price range', | |
| 'bundle_weight_type' => 'dynamic', | |
| 'bundle_values' => implode('|', $options), | |
| 'bundle_shipment_type' => 'together' | |
| ]; | |
| } | |
| $handle = fopen($file, 'w'); | |
| fputcsv($handle, $columns, ','); | |
| foreach ($data as $item) { | |
| fputcsv($handle, $item, ',', '"'); | |
| } | |
| fclose($handle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment