ginotoffoli Posted April 14, 2014 Share Posted April 14, 2014 (edited) Hi, I am developing a script to automatic import csv files in prestashop 1.5.6. I know that there are modules out there but I am doing a custom one. This is the script I'am using is from here and it works for categories and products, but I have problems on combinations. I am trying to understand how to add combinations. <?php define('_PS_ADMIN_DIR_', getcwd()); include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); include(_PS_ADMIN_DIR_.'/functions.php'); if (!isset($_GET['entity'])) die(); $import = new AdminImportController(); switch ($_GET['entity']) { case 0: loadCategoriesPost(); $import->categoryImport(); break; case 1: loadProductsPost(); $import->productImport(); break; case 2: loadCombinationsPost(); $import->attributeImport(); break; } function loadCategoriesPost() { $_POST = array ( 'tab' => 'AdminImport', 'skip' => '1', 'csv' => '20131209133157-categoria2.csv', 'convert' => '', 'entity' => '0', 'separator' => ';', 'multiple_value_separator' => ',', 'import' => '1', 'iso_lang' => 'es', 'forceIDs' => '1', 'type_value' => array ( 0 => 'id', 1 => 'active', 2 => 'name', 3 => 'parent', 4 => 'is_root_category', 5 => 'description', 6 => 'meta_title', 7 => 'meta_keywords', 8 => 'meta_description', 9 => 'link_rewrite', 10 => 'image', 11 => 'shop' ), ); } function loadProductsPost() { $_POST = array ( 'tab' => 'AdminImport', 'skip' => '1', 'csv' => '20131210093530-productos2.csv', 'convert' => 'on', 'regenerate' => '', 'entity' => '1', 'iso_lang' => 'es', 'match_ref' => '1', 'separator' => ';', 'multiple_value_separator' => ',', 'import' => '1', 'type_value' => array ( 0 => 'id', 1 => 'active', 2 => 'name', 3 => 'category', 4 => 'price_tex', 5 => 'id_tax_rules_group', 6 => 'wholesale_price', 7 => 'on_sale', 8 => 'reduction_price', 9 => 'reduction_percent', 10 => 'reduction_from', 11 => 'reduction_to', 12 => 'reference', 13 => 'supplier_reference', 14 => 'supplier', 15 => 'manufacturer', 16 => 'ean13', 17 => 'upc', 18 => 'ecotax', 19 => 'width', 20 => 'height', 21 => 'depth', 22 => 'weight', 23 => 'quantity', 24 => 'minimal_quantity', 25 => 'visibility', 26 => 'additional_shipping_cost', 27 => 'unity', 28 => 'unit_price_ratio', 29 => 'description_short', 30 => 'description', 31 => 'tags', 32 => 'meta_title', 33 => 'meta_keywords', 34 => 'meta_description', 35 => 'link_rewrite', 36 => 'available_now', 37 => 'available_later', 38 => 'available_for_order', 39 => 'available_date', 40 => 'date_add', 41 => 'show_price', 42 => 'image', 43 => 'delete_existing_images', 44 => 'features', 45 => 'online_only', 46 => 'condition', 47 => 'customizable', 48 => 'uploadable_files', 49 => 'text_fields', 50 => 'out_of_stock', 51 => 'advanced_stock_management', 52 => 'shop' ), ); function loadCombinationsPost() { $_POST = array ( 'tab' => 'AdminImport', 'skip' => '1', 'csv' => 'comb.csv', 'convert' => 'on', 'entity' => '2', 'iso_lang' => 'it', 'separator' => ';', 'multiple_value_separator' => ',', 'type_value' => array ( 0 => 'id_product', 1 => 'group', 2 => 'attribute', 3 => 'quantity', 4 => 'reference' ), ); } Edited April 14, 2014 by ginotoffoli (see edit history) Link to comment Share on other sites More sharing options...
denverrenee3 Posted October 22, 2014 Share Posted October 22, 2014 Would you have any input on how to modify this for customer csv file instead of products? Link to comment Share on other sites More sharing options...
Recommended Posts