import promblem when field contain comma

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #65632

I found a problem:
I import categories, one of them contains comma (for exapmle "fish, meat, vegetables")
hikashop creates 3 categories instead one: "fish" " meat" " vegetables"
file *.csv attached (19 line)

Attachments:
Last edit: 11 years 7 months ago by 8stinger8.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 7 months ago #65756

Yes, that's normal. You can have several categories separated by a comma.
You will have to use something else than the comma if you don't want that or you should do it differently.
For example, you could create that category and then have the category id instead of the category name in the categories column of your CSV.

The following user(s) said Thank You: 8stinger8

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

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #65872

Thank you! I understand.
But I have another question:
when I import products, and if product ends with quotes, then in hikashop appears without last quotes
for example I have in my *.csv procuct soap "sheep", in hikashop it imports as soap "sheep
but if the last char not quotes, then everything good (soap "sheep" small --> soap "sheep" small)

Attachments:

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 7 months ago #65873

Then you should have the text of the column like that: "soap ""sheep"""
The first " and the last will delimit the data of the column and the "" will be converted to " during the import.

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

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #65877

I do so (see my test.csv in 6 line) and the last " lose

Attachments:
Last edit: 11 years 7 months ago by 8stinger8.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 7 months ago #65883

Please replace the line:
$newProduct->$field = trim($value,'\'" ');

by:
$newProduct->$field = preg_replace('#^[\'" ]{1}(.*)[\'" ]{1}$#','$1',$value);

in the file administrator/components/com_hikashop/helpers/import.php and try again.

The following user(s) said Thank You: 8stinger8

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

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #65890

It's work!
thanks a lot!
:)

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

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #65976

I have another question
field product_description during import lose html tags
(<p>text1<br />text2 text3 text4 text5<br />text6 text7</p> --> text1text2 text3 text4 text5text6 text7)

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 7 months ago #66123

It's probably your HTML editor which strips out the tags because it's working fine on our end.

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

  • Posts: 8
  • Thank you received: 0
11 years 7 months ago #66159

no, I found that it happend after I replace
$newProduct->$field = trim($value,'\'" ');
by:
$newProduct->$field = preg_replace('#^[\'" ]{1}(.*)[\'" ]{1}$#','$1',$value);

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 7 months ago #66416

Then I have no idea.
Can you do an import while having the debug mode of the joomla configuration activated and give the traces printed at the bottom of the page ?

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

  • Posts: 6
  • Thank you received: 0
11 years 6 months ago #68857

How can a field name (e.g. categories) that contain comas (e.g. "books, magazines and cards") be imported as such. I thought you can change the field separator character (e.g. tab, |, etc).
Thanks

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 6 months ago #68967

You can use tab or comma or semi colon as field separator. Also, If you have double quotes around your fields, you can even use the same character as the separator in the value of the field.

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

  • Posts: 6
  • Thank you received: 0
11 years 6 months ago #69046

Thanks Nicolas.
One more question: where do you select the field separator in the back panel of Hikashop?

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 6 months ago #69066

For the import, it's detected automatically.
For the export, there is an option for that in the Files/Images tab of the configuration.

The following user(s) said Thank You: cosg2004

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

Time to create page: 0.098 seconds
Powered by Kunena Forum