product not found

  • Posts: 71
  • Thank you received: 1
3 years 9 months ago #328815

-- HikaShop version -- : 4.4.0

Hey,

I want to import a pricelist through mass actions but I get the message

The line '5425026281076;165' could not be imported Product not found

My basic csv files looks like
product_code;price_value_with_tax
5425026281076;165

When I do a query in PHPmyadmin
SELECT * FROM `a2ego_hikashop_product` where product_code='5425026281076'
I got one result.

Why is the product not found? Is there a debug mode for the import?

Best regards,
RG

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 9 months ago #328816

Hi,

That was quite a tricky one to understand :)
The issue comes from several things:
- the first column of your CSV is the product_code, which is necessary to properly import the products
- your file is saved as a UTF8 with BOM. This means that at the beginning of the file, there is a ZERO WIDTH NO-BREAK SPACE character.
- the mass action system doesn't handle properly the files with BOM and thus the BOM character gets added to the column name of the first column which leads to the first column not being found.
The problem is that since it's a zero width character, you can't see that BOM character when you open the file with notepad++ or when you look at the error message HikaShop provides. So you can't see that the issue comes from that character.
After some debugging, I found that strange character there, which lead me to this page:
stackoverflow.com/questions/9691771/why-...appearing-in-my-html
And thus I was able to put together a solution.
You just need to add the code :

$fileWithBOM = (substr($contentFile,0,3) == pack("CCC",0xef,0xbb,0xbf));
		if($fileWithBOM)
			$contentFile = substr($contentFile, 3);
before the line:
$contentFile = str_replace(array("\r\n","\r"),"\n",$contentFile);
in the file administrator/components/com_hikashop/classes/massaction.php
This will cut out the BOM character at the beginning if present and your file will then import properly.
We'll add that patch on our end.

The following user(s) said Thank You: RG

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 1
3 years 9 months ago #328833

Nice one!

I saved it as UTF without bom and now the import is good.

Thanks!

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum