franco.pentangeli Posted November 21, 2013 Share Posted November 21, 2013 Hi, I have to import 1500 products from csv (turbo lister from ebay), but I have a problem. When I try to import them, Prestashop doesn't recognize same categories so it creates new ones. How can I resolve it? thanks Link to comment Share on other sites More sharing options...
RogueWaveLimited Posted November 21, 2013 Share Posted November 21, 2013 The categories are taken as strings so any variation like a leading or trailing blank on one but not the other will cause this to happen. For example " 123" may not be the same as "123 " which may be different from "123". Link to comment Share on other sites More sharing options...
franco.pentangeli Posted November 21, 2013 Author Share Posted November 21, 2013 The categories are taken as strings so any variation like a leading or trailing blank on one but not the other will cause this to happen. For example " 123" may not be the same as "123 " which may be different from "123". Hi rogue, You are right, but my csv is created with Turbo Lister. So I haven't any space or characters that change the category' string. thank you. F Link to comment Share on other sites More sharing options...
RogueWaveLimited Posted November 21, 2013 Share Posted November 21, 2013 If you'll email me the CSV and I'll take a look at it. Link to comment Share on other sites More sharing options...
franco.pentangeli Posted November 21, 2013 Author Share Posted November 21, 2013 If you'll email me the CSV and I'll take a look at it. Thanks! I have send my example csv to your email address. F Link to comment Share on other sites More sharing options...
jai35 Posted January 21, 2014 Share Posted January 21, 2014 I can fix : change file controllers/admin/ AdminImportController.php line 1269: if (is_numeric($value)) { if (Category::categoryExists((int)$value)) $product->id_category[] = (int)$value; else { $category_to_create = new Category(); $category_to_create->id = (int)$value; $category_to_create->name = AdminImportController::createMultiLangField($value); $category_to_create->active = 1; $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY'); // Default parent is home for unknown category to create $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]); $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite); if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) $product->id_category[] = (int)$category_to_create->id; else { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], (isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } } else if (is_string($value) && !empty($value)) to //if (is_numeric($value)) // { // if (Category::categoryExists((int)$value)) // $product->id_category[] = (int)$value; // else // { // $category_to_create = new Category(); // $category_to_create->id = (int)$value; // $category_to_create->name = AdminImportController::createMultiLangField($value); // $category_to_create->active = 1; // $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY'); // Default parent is home for unknown category to create // $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]); // $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite); // if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && // ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) // $product->id_category[] = (int)$category_to_create->id; // else // { // $this->errors[] = sprintf( // Tools::displayError('%1$s (ID: %2$s) cannot be saved'), // $category_to_create->name[$default_language_id], // (isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' // ); // $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). // Db::getInstance()->getMsgError(); // } // } // } if (!empty($value)) Link to comment Share on other sites More sharing options...
Recommended Posts