Jump to content

Default category CSV problem!


Recommended Posts

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. :( thx

 

post-374708-0-72535500-1350233697_thumb.jpg

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hello, I have the same problem, is a tree category of Home, and I tried putting:

 

"Home, Pruebas"

"Home, Pruebas"

"Pruebas"

 

and always shows only only.. the category "Home"

 

I'm use Prestashop 1.5.3.1

 

and the official CSV template

 

would appreciate a solution to import through CSV and is an essential tool

 

Certainly would not hurt a function to export it? although to do so cumbersome using mysql help

 

87240832.png

Edited by ibairg (see edit history)
Link to comment
Share on other sites

I'm no expert, but I think it has something to do with that part of MySql should create a new row only changing the id_category

 

using mysql and already does this value:

 

INSERT INTO `` myshop1. MyShop_category_product `` (

id_category ``,

id_product ``,

`position`

)

VALUES (

'2 ', '2', '3 '

);

 

but would have to create one for the other category we write in the csv:

 

INSERT INTO `` myshop1. MyShop_category_product `` (

id_category ``,

id_product ``,

`position`

)

VALUES (

'11 ', '2', '3 '

);

 

i don't know if it is BUG or not are the code to this action, because I'm not a php expert

Link to comment
Share on other sites

  • 2 weeks later...

Solution:

Line 645 and Line 647 in - controllers/admin/AdminImportController.php

Change:

line 645 do $uniqid = uniqid(); while (file_exists(_PS_UPLOAD_DIR_.$uniqid));

$tmp_file = file_put_contents($uniqid, $field);

line 647 $fd = fopen($temp, 'r');

$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);

fclose($fd);

To:

   	 do $uniqid = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid));
       $tmp_file = file_put_contents($uniqid, $field);
       $fd = fopen($uniqid, 'r');
       $tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
       fclose($fd);

 

OR comment out lines 636 - 656 (until the issue is resolved) and ADD the lines

protected static function split($field)
   {
       if (empty($field))
           return array();

       if (is_null(Tools::getValue('multiple_value_separator')) || trim(Tools::getValue('multiple_value_separator')) == '')
           $separator = ',';
       else
           $separator = Tools::getValue('multiple_value_separator');

       $temp = tmpfile();
       fwrite($temp, $field);
       rewind($temp);
       $tab = fgetcsv($temp, MAX_LINE_SIZE, $separator);
       fclose($temp);
       if (empty($tab) || (!is_array($tab)))
           return array();
       return $tab;

   }

 

Either one of these options works, not sure which is better. Solves both the 'No Image' issue and the category 'always being Home' issue. Hope this helps everyone.

Thanks to this poster and github https://github.com/PrestaShop/PrestaShop/commit/8d7196daf3b39d280c631882f0e3ebe473233d07 for pointing me in the right direction. His solution changes more than needs to be to resolve the issue, and was harder to find the I hope this will be.

  • Like 2
Link to comment
Share on other sites

It is surprising that we have come so far in the community edition, but never has this issue been officially resolved in the 1.5 releases?

 

Importing into certain category is a basic feature, and again i am surprised that it went un-noticed in all the previous version...

 

as of now out of the box it still does not work, i.e. all products goto home category! 1.5.3.1

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

I mean you can either change the two lines that need to be changed (Line 645 and Line 647 in - controllers/admin/AdminImportController.php)

Change:

line 645

do $uniqid = uniqid(); while (file_exists(_PS_UPLOAD_DIR_.$uniqid));

 

line 647

$fd = fopen($temp, 'r');

 

To:

line 645

do $uniqid = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid));        

 

line 647      

$fd = fopen($uniqid, 'r');        

OR comment out lines /*636 - 656*/ = Add this /* to the front of line 636, add this */ to the end of line 656

(until the issue is resolved) = until they fix this code so you don't have to make changes

and ADD the lines = copy and paste the posted code just after section of code you just commented out.

 

Doing it this way leaves the original code in place should you need it for any reason.

Link to comment
Share on other sites

×
×
  • Create New...