Peda Posted September 18, 2012 Share Posted September 18, 2012 (edited) Hi, Prestashop 1.5 final imports categories.csv, but not using my defined ID's. It assigns its auto-increment ID's. Not my ID's. So, everything goes wrong with my sub-categories. Could someone knows the solution? Regards Edited February 8, 2013 by Peda (see edit history) Link to comment Share on other sites More sharing options...
E-raser Posted September 18, 2012 Share Posted September 18, 2012 Hi, Same problem here Bug created on forge PSCFV-4069 Br, E-raser Link to comment Share on other sites More sharing options...
silberstern Posted September 18, 2012 Share Posted September 18, 2012 Have you manage to import csv products having more than one feature? Link to comment Share on other sites More sharing options...
Peda Posted September 18, 2012 Author Share Posted September 18, 2012 I have to import categories.csv before product.csv But still I have no success to import categories.csv Link to comment Share on other sites More sharing options...
Peda Posted September 20, 2012 Author Share Posted September 20, 2012 (edited) If categories_import.csv file (ps sample file) has to assigning its own auto-increment ID's, so why there is an ID column in the categories_import.csv file, I don't understand. Could someone advice to me, if there is a way to assign my own ID numbers to my categories and sub-categories without auto-increment? Edited September 20, 2012 by Peda (see edit history) Link to comment Share on other sites More sharing options...
xchriz Posted September 21, 2012 Share Posted September 21, 2012 Hi, same problem also for me. I've found that the problem isn't in the import code, but in the "global" save method. Now, i use a temporary workaround, an override of class "ObjectModel". Code causing problem autoincrement : /classes/ObjectModel.php ; method : add ; rows : 460-462 // Database insertion if (isset($this->id)) unset($this->id); In the override file : /override/classes/ObjectModel.php I've copied the entire method and then simply commented the 2 rows. I'm thinking to use this workaround only for the import step, I don't know if it may cause other problems. I hope this will be useful. Best regards Link to comment Share on other sites More sharing options...
Peda Posted September 21, 2012 Author Share Posted September 21, 2012 (edited) Thank you Xchriz. I will try your solution now. The worst part of this issue is: I have 50 000 products, 19 000 sub-categories. Ok I import the categories.csv by prestashops auto ID method, then start to preparing the products.csv. In the products.csv file the 4th column is Categories (x,y,z...) column. I am preparing this column with my own category ID's. Like this: 67452, 67456, 67472, 67451, 67075, 67079, 67081, 67082 (Detailed image at below) After this, while importing the product.csv, prestashop looks for its own auto-increment ID's in the 4th column (Categories (x,y,z...) column) of product.csv file. How can I prepare again this categories column (50 000 rows) in products.csv according to prestashops auto-increment ID's? Products.csv screenshot Edited September 21, 2012 by Peda (see edit history) 1 Link to comment Share on other sites More sharing options...
xchriz Posted September 21, 2012 Share Posted September 21, 2012 If you use the above workaround, it is Global. That means all creations of prestashop entities are involved, therefore also all kind of CSV imports... If you import the categories with your old/original ID, you can then import products with your old/original ID and its related old/original IDs of categories. My English is not so good, i hope i've explained it Link to comment Share on other sites More sharing options...
Ninja Of Web Posted September 21, 2012 Share Posted September 21, 2012 Hi, It's not a bug It exist 3 posibilities when importing categories: "id_category" is empty : we add this category with auto incrementation "id_category" isn't empty : if "id_category" exist in your the table category, we update this category if "id_category" not exist in your the table category, we add this category In your case, the "id_category" doesn't exist. Well, we add this category ! Best regards, Loïc. Link to comment Share on other sites More sharing options...
xchriz Posted September 21, 2012 Share Posted September 21, 2012 Yes, but this behavior is not suitable to this scenario : I've a highly customized old prestashop (1.3) so ti perform the upgrade i've decided to build a new clean installation of PS 1.5. I need to import old data into the new system BUT i need to preserve the old primary-keys. The import procedure if the category doesn't exists in db will always create a new primary-key, for a given csv like : ID;categoryname 10;alfa 20;beta 30;gamma the import's result will be 3;alfa 4;beta 5;gamma And this is a very big problem, especially because i need to maintain the associations between categories and products. Br, Chris 1 Link to comment Share on other sites More sharing options...
E-raser Posted September 21, 2012 Share Posted September 21, 2012 Hi, It's not a bug It exist 3 posibilities when importing categories: "id_category" is empty : we add this category with auto incrementation "id_category" isn't empty : if "id_category" exist in your the table category, we update this category if "id_category" not exist in your the table category, we add this category In your case, the "id_category" doesn't exist. Well, we add this category ! Best regards, Loïc. Hi Loïc, I think there is still a bug please see http://forge.prestashop.com/browse/PSCFV-4285 when you import categories, prestashop will override the ID's from the csv, this means the sub-categories parent ID numbers aren't correct any more. This is the same with products & combinaties If prestashop changes the product ID's given in de product.csv, the main products id's in the combinations file aren't correct any more. Br, E-raser Link to comment Share on other sites More sharing options...
Peda Posted September 21, 2012 Author Share Posted September 21, 2012 (edited) Hi, It's not a bug It exist 3 posibilities when importing categories: "id_category" is empty : we add this category with auto incrementation "id_category" isn't empty : if "id_category" exist in your the table category, we update this category if "id_category" not exist in your the table category, we add this category In your case, the "id_category" doesn't exist. Well, we add this category ! Best regards, Loïc. Hi, Mr. Loïc I agree with xchriz and E-raser. Ok I see, youre right, if the id_category column is empty than lets process it with auto-increment. But in my category.csv file, the id_category column filled with my own ID's. Its full of my own assigned ID's. And I am using these ID's in my product.csv file in Categories (x,y,z...) column. So, this way my thousand of products goes to their sub-categories correctly. The result is, I have to use my own category ID's to import my product.csv correctly. Regards Edited September 23, 2012 by Peda (see edit history) Link to comment Share on other sites More sharing options...
silberstern Posted September 22, 2012 Share Posted September 22, 2012 I had same issue with product ids. Even if in the csv file I have specified product id, it turned out to have another one after import. Thanks for the tip xchariz. Link to comment Share on other sites More sharing options...
Nelson Posted September 23, 2012 Share Posted September 23, 2012 (edited) Il s'agit vraiment d'un sérieux bug! Qui empêche toutes utilisation de la version de Prestashop 1.5.17 du moins pour l'importation de catégorie avec utilisation de son propre ID. Cette erreur et très dommageable et bloc l'utilisation de la dernière version pour l'importation de csv! La solution proposé plus haut dépanne, mais cela n'es pas digne d'une version stable, car ce problème impacte de façon très large l'utilisation de Prestashop par rapport à l'import de catégorie et de produits via des fichiers csv, ce qui est très souvent utilisé. Le bug tracker http://forge.prestas...owse/PSCFV-4285 est pris en charge par Loic Lefevre. Edited September 23, 2012 by Nelson (see edit history) Link to comment Share on other sites More sharing options...
rseigel Posted September 23, 2012 Share Posted September 23, 2012 Ummm....English only in this forum please. Link to comment Share on other sites More sharing options...
Ninja Of Web Posted September 24, 2012 Share Posted September 24, 2012 Hi, Ok I understand your problem. But if i fix it, it is possible that bugs the multi-shops appear... I will be try to fix this bug before the next version. Best regards, Loïc. Link to comment Share on other sites More sharing options...
Peda Posted September 24, 2012 Author Share Posted September 24, 2012 So, me and other users who have to import their bulk .csv files, can not use Ps 1.5 until next version. This is really painful. If there is a workaround by changing some file/s, please tell. At least, a lot user can use Ps 1.5. Simple suggestion: I want to use Ps 1.5 for its new technology + performance + new look. For not multi shop. If I can use my single shop properly and efficiently then I can start to think using multi shop. But not now. Maybe you can put a radio button option for ID's. So I do not use multi shop, but I can import my .csv files properly. Regards 1 Link to comment Share on other sites More sharing options...
E-raser Posted September 24, 2012 Share Posted September 24, 2012 (edited) Hi, I found a temporary work around for importing categories that worked for me: 1) fresh install (or make sure in your db ps_category,ps_category_group,ps_category_lang, ps_category_shop has only the default categories (category root & home, ID 1 & 2)) 2) as xchriz already said, in classes/ObjectModel.php on line 460 change: if (isset($this->id)) unset($this->id); to // if (isset($this->id)) // unset($this->id); 3) import your categories csv, make sure your main categories have category id 2 as parent category 4) put classes/ObjectModel.php back to normal I don't know if this will work for products/combinations. Br, E-raser Edited September 24, 2012 by E-raser (see edit history) 2 Link to comment Share on other sites More sharing options...
l-goodwin Posted September 24, 2012 Share Posted September 24, 2012 I have imported a few csv files into 1.5 and the above is true, the ID does auto increment. Another problem I have found is that when I import the products, they don't show under their categories in B/O. I haven't managed to import combinations yet because I don't understand the setup in 1.5 1 Link to comment Share on other sites More sharing options...
PatriceJV Posted September 27, 2012 Share Posted September 27, 2012 Hi, I found a temporary work around for importing categories that worked for me: 1) fresh install (or make sure in your db ps_category,ps_category_group,ps_category_lang, ps_category_shop has only the default categories (category root & home, ID 1 & 2)) 2) as xchriz already said, in classes/ObjectModel.php on line 460 change: if (isset($this->id)) unset($this->id); to // if (isset($this->id)) // unset($this->id); 3) import your categories csv, make sure your main categories have category id 2 as parent category 4) put classes/ObjectModel.php back to normal I don't know if this will work for products/combinations. Br, E-raser This worked for me 1 Link to comment Share on other sites More sharing options...
YHK_Prestashop Posted September 29, 2012 Share Posted September 29, 2012 This workaround to comment out the two lines of code does work for importing products with your own ID's. However im still having the issue for the prodcuts i import its not putting them in any categry. I have tried using the cateogry Name and the exisiting category ID number to import, with no luck. Link to comment Share on other sites More sharing options...
azphones Posted October 2, 2012 Share Posted October 2, 2012 (edited) thanks for the work around!! it for some reason took me 3 tries to get it to work without a ID (Null) error but yeah it's working now, thx. X Edited October 2, 2012 by azphones (see edit history) Link to comment Share on other sites More sharing options...
Ninja Of Web Posted October 2, 2012 Share Posted October 2, 2012 Hi all, I have added an option which can force your id's for the product import and category import. Be careful : if you use the multistore with the product sharing, it's preferable to make your imports before activating the multistore. Thanks for your report ! Best regards, Loïc. Link to comment Share on other sites More sharing options...
inform Posted October 2, 2012 Share Posted October 2, 2012 I do not work the solution of the two line comment, any ideas? Link to comment Share on other sites More sharing options...
a1b2 Posted October 2, 2012 Share Posted October 2, 2012 Hi all, I have added an option which can force your id's for the product import and category import. Be careful : if you use the multistore with the product sharing, it's preferable to make your imports before activating the multistore. Thanks for your report ! Best regards, Loïc. Thank you. I need to install all again or I can change only some files like "classes/ObjectModel.php"? Link to comment Share on other sites More sharing options...
Ninja Of Web Posted October 3, 2012 Share Posted October 3, 2012 Thank you. I need to install all again or I can change only some files like "classes/ObjectModel.php"? Hi, No, you must do more change. See this revision : 17684 on the SVN Or my modifications on the SCM here : http://scm.prestashop.com/changelog/PrestaShop_v.1.5.x?cs=17684 Best regards, Loïc. Link to comment Share on other sites More sharing options...
Bejo Posted October 14, 2012 Share Posted October 14, 2012 i'm tried import products with csv on ps 1.5.1 everything success. but the default category products automatic being in Home Category. ID insert this at Categories(x,y,z...) csv -> still can fully understand about this condition. Example: already tried this - Home, iPods iPods, iPods Battery ( success but default category automatic being -Home ), how to made default category is -iPods Battery. and i tried ; - iPods Battery, Home, iPods iPods, iPods Battery ( everything categories is missing with this condition). Wishing somebody can give hand to me! thank already searching but nothing. Link to comment Share on other sites More sharing options...
Jubri Posted October 23, 2012 Share Posted October 23, 2012 (edited) Hi! Related to this thread, ... I'm trying to create Category via Code. $category = new Category(50); ... but never assigns id=50 to new Object, only autoincremental value. Problem exists, when i assign ID in constructor and ID not exists in database. With this fix... it works for me: ObjectModel.php (@version Release: $Revision: 7499) Line:217 ... $result = Cache::retrieve($cache_id); if ($result) { ... } ... Fix ... $result = Cache::retrieve($cache_id); if ($result) { ... } else $this->id = (int)$id; ... It's correct? Regards Edited October 23, 2012 by Jubri (see edit history) Link to comment Share on other sites More sharing options...
carelessoul Posted November 7, 2012 Share Posted November 7, 2012 You must Force Load all the ID's during import to prevent from auto-incrementing. Link to comment Share on other sites More sharing options...
sashax Posted November 15, 2012 Share Posted November 15, 2012 same for me... i need to not auto increment category id. so bad... Link to comment Share on other sites More sharing options...
romeo.angelin Posted November 20, 2012 Share Posted November 20, 2012 Hello! I need some help .. if it's possible i need an.. sample CSV with 5 - 10 categories created on 3rd level.. other.. not same CSV sample.. from PrestaShop Admin Panel.. Please .. Thank you.. Link to comment Share on other sites More sharing options...
BJC Posted November 28, 2012 Share Posted November 28, 2012 Hello! I have been following this thread and require assistance. My main issue is the inability to use my own product id numbers - they get replaced with an auto-generated number when i do a csv upload. I'm currently running 1.5.0.17 and am wondering if this has been resolved in the latest version 1.5.2? I really need a solution for this. Thanks! Link to comment Share on other sites More sharing options...
sashax Posted November 28, 2012 Share Posted November 28, 2012 it seams is the same for 1.5.2... too bad... prestashop lack of basic feature is disarming! 1 Link to comment Share on other sites More sharing options...
mobilafitness Posted November 28, 2012 Share Posted November 28, 2012 ... so hard to find a solution for this, I want to upgrade to 1.5.2 as well, but no success with database Link to comment Share on other sites More sharing options...
csid Posted December 27, 2012 Share Posted December 27, 2012 Hello Loic, I have seen in ObjectModel.php that you added "&& !Tools::getValue('forceIDs')" I want to use add method from a script i made myself with ids forced. How can I force this flag in my script?? Wich method from Tools do I have to use to put the value in "forceIds" ? I searched a "setValue()" but didn't found it............ (you can answer me in french in if you want) Link to comment Share on other sites More sharing options...
Sippa Posted December 30, 2012 Share Posted December 30, 2012 (edited) Im also experiencing the same problem using 1.5.3 when importing products. (importing categories works as intended). That is: even with forced id-s you get auto-increment. Also getting the following errors with products : import replaces categories with "home" (even with the sample csv file that PS provides), so the uploaded products are all in "home" instead of the desired categories/subcategories Pictures are not uploaded (suprisingly image upload works with category import, but not with products) Edited December 30, 2012 by Sippa (see edit history) Link to comment Share on other sites More sharing options...
elvispl Posted January 16, 2013 Share Posted January 16, 2013 Has anyone solved the problem? Link to comment Share on other sites More sharing options...
guidoakd Posted January 24, 2013 Share Posted January 24, 2013 Hi. I have the same problem. No only with products, also in categorys. In my cvs i have ID:5, and after importing, appears as 25. It's so difficult to do something with this, because it makes changes everywhere you use IDs. But.. anyone know how to "erase all" in order to start again with ID 1? Somebdoy put some cod about truncating, but don't know where to put it. Good bye and thanks Link to comment Share on other sites More sharing options...
antoniony Posted January 24, 2013 Share Posted January 24, 2013 (edited) SOLVED! Finally the solution with CSV products Categories import is here https://github.com/P...f233883e36da2cf Just add to file AdminImportController.php (controllers/admin/AdminImportController.php) before line 1151 : if(isset($info['category'])) $product->category = explode($this->multiple_value_separator, $info['category']); P.S. One more - try to use ID's (for example 32,46). When I used categories name, there still have some problem. With ID's everything fine! Edited January 24, 2013 by antoniony (see edit history) Link to comment Share on other sites More sharing options...
steinsgate Posted January 31, 2013 Share Posted January 31, 2013 Prestashop 1.5.3.1 has an option to "force ids" when importing. SOLVED! Finally the solution with CSV products Categories import is here https://github.com/P...f233883e36da2cf Just add to file AdminImportController.php (controllers/admin/AdminImportController.php) before line 1151 : if(isset($info['category'])) $product->category = explode($this->multiple_value_separator, $info['category']); P.S. One more - try to use ID's (for example 32,46). When I used categories name, there still have some problem. With ID's everything fine! Link to comment Share on other sites More sharing options...
Generaal Posted May 20, 2013 Share Posted May 20, 2013 Hello, have someone found the setting in V1.5.4.1 to import cat and sub cat? The example file from the shop are so basic and contains only à few main categories. I startend with it, read many forums and nothing will works on these version, only creating main catogories. Thnx in advance, Generaal Link to comment Share on other sites More sharing options...
Recommended Posts