Questions about importing product with variants from csv

  • Posts: 205
  • Thank you received: 12
3 years 6 months ago #332485

-- HikaShop version -- : 4.4.2
-- Joomla version -- : 3.9.25
-- PHP version -- : 7.4.14

Hello

We need a solution to the following issue.

imported one main product with five variants through a csv file.

question 1
The "main" product_id does not exist before the import so we can not set product_parent_id for the "variant" records in the csv file that we want to import. Tried to use the "product_code" of the main product as "product_parent_id" but during the import it changes to "0". How can we solve this problem

Question 2
The appropriate characteristics (megethos and color on our sample csv) have been created but they are not applied to the "main" product. We had to apply the characteristics to the main product manualy after the import.

Question 3
After applying the appropriate characteristics to the imported "main" product, there is no default value for each characteristic selected and we had to select manually. What is the way to set the default value to the variants?

We attach the csv file that we used in case you need to check.

File Attachment:

File Name: test_variants.csv
File Size:15 KB


Please advise...

PS: Noticed that the "product_parent_id" field in #__hikashop_product table is int(11). The imported product code contains letters (example: F1005104). Is this the reason why the "product_parent_id" is always "0" after import? Normally this should accept letters as well.

Thank you

Attachments:
Last edit: 3 years 6 months ago by liaskas. Reason: Notice about product_parent_id column

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
3 years 6 months ago #332495

Hi,

Your CSV is not bad, but I'm surprised it works at all.
The column titles are missing the prefix product_ for almost all of them.
type should be product_type, code should be product_code, category should be categories, name should be product_name, description should be product_description, image1 image2 image3 and image4 should be regrouped into one column separated with commas or semi colons with the column name "images", etc.
Please create a product like you want via the interface and export it. Then, open the CSV generated and you'll see all the correct column names you should use.
Also, note that if all the variants have the same text as the main product for a column, you can only fill the cell of the main product and leave the variants cell empty. That way, the variants will automatically use the information of the main product on the product details page.

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

  • Posts: 205
  • Thank you received: 12
3 years 6 months ago #332499

We tried importing using... Hikashop - Product Cron Update and then tried RO CSVI
We have set the column names and the corresponding database name. anyway... it is imported!

Noticed that the "product_parent_id" field in #__hikashop_product table is int(11). The imported product code contains letters (example: F1005104). Is this the reason why the "product_parent_id" is always "0" after import? Normally this should accept letters as well.

May that be the problem?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
3 years 6 months ago #332502

Hi,

It's normal that the product_parent_id is 0 for the main product in the database.
It should be the id of the parent product for the variant entries in the hikashop_product table.
If you have 0 in there for the variant entries after a HikaShop import, it means that the import saw the variant rows as main products and not variants of the first entry (probably because the "type" and "parent_id" columns should be named "product_type" and "product_parent_id" in the CSV).

I can't comment on RO CSVI. I don't know how it handles variants import.

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

  • Posts: 205
  • Thank you received: 12
3 years 6 months ago #332528

This is not true.

I try to enter the value "F1005104" directly in the database product_parent_id field and it changes it to "0"
I tried to enter the value "1005104" (same without the "F") and it was accepted.

Are you sure that an int(10) Numeric Data Type accepts letters?

Last edit: 3 years 6 months ago by liaskas.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
3 years 6 months ago #332544

Hi,

What is not true ?
Everything you say in your message after this is compatible with what I say in my previous message.
I never said that the product_parent_id column in the database accepts letters, which it doesn't.
As I said:

It's normal that the product_parent_id is 0 for the main product in the database.
It should be the id of the parent product for the variant entries in the hikashop_product table.

So either the value should be 0 or the product_id of the variant in that same table. And the product_id is always a number since it's an auto_increment integer column.

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

  • Posts: 205
  • Thank you received: 12
3 years 6 months ago #332548

As you mentioned in your first reply CSV is not bad

No matter what the column names are...



i made this csv according to your suggestions here...

www.hikashop.com/forum/import-export-csv...ame-time.html#288289
In that post you provide an image that contains this:


Anyway....
can you please tell us what we have to do (step by step) to make the import from csv work?

If we need to change something in the csv, please tell us what.

Attachments:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
3 years 6 months ago #332549

Hi,

In the CSV file, in the "product_parent_id" column of variant rows, you need to have the product_code of the main product row, not the product_id. And YES, in the CSV file, the column product_parent_id can have letters.
The import script will automatically replace the product_code in that column with the product_id of the main product.
This is because when you import a new product, it doesn't have yet a product_id, but you still need to link the variants to the main product in the product_parent_id column. Thus, we're using the product_code in the product_parent_id column of the CSV instead.

I already told you what you should do to change your CSV file in my first message:

The column titles are missing the prefix product_ for almost all of them.
type should be product_type, code should be product_code, category should be categories, name should be product_name, description should be product_description, image1 image2 image3 and image4 should be regrouped into one column separated with commas or semi colons with the column name "images", etc.
Please create a product like you want via the interface and export it. Then, open the CSV generated and you'll see all the correct column names you should use.
Also, note that if all the variants have the same text as the main product for a column, you can only fill the cell of the main product and leave the variants cell empty. That way, the variants will automatically use the information of the main product on the product details page.

In all your messages here since then, you didn't talk about all that I said in that quote and just talked about the product_parent_id column.
Please do the modifications I talked about and try again.
If that still doesn't work, please provide your new CSV file so that I can tell you what you're still missing in it.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum