Import Product With CSV - can change variants default to another variants?

  • Posts: 548
  • Thank you received: 11
  • Hikamarket Multivendor Hikashop Business
6 months 3 weeks ago #355651

-- HikaShop version -- : 5.0.0
-- Joomla version -- : 3.9.21
-- PHP version -- : 7.2

Hi

Want to change the default variants of 1000+ products, is there a way we can do this update using CSV?

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
6 months 3 weeks ago #355655

Hi,

That's going to be a lot of work to do this with a CSV export/import.

I think it will be way better to do this by running a MySQL query via your PHPMyAdmin.
I think such a MySQL query will do the job:

UPDATE #__hikashop_variant as v, #__hikashop_product as p SET v.variant_characteristic_id=XXX WHERE v.variant_product_id=p.product_id AND p.product_parent_id=0 AND v.variant_characteristic_id=YYY
where #__ is the table prefix of your tables, YYY is the characteristic_id of the old default value and XXX the characteristic_id of the new default value. In order to find these ids, you first need to open the hikashop_characteristic table via your PHPMyAdmin and look for these value rows.
That way, you can do it in 2 minutes.

Note however:
- it requires the new default variant to already exist in the products. If you have a characteristic color with the values red, blue and white, and you have a product with only red and blue added to it, if you want to change the default value to white, this won't work properly as the default color value product will be assigned to the product for a variant which it doesn't have yet.
- If you mess up, it can screw your product data. Make so you backup your database before, or even better, test the procedure on a copy of the website.
- I didn't test that MySQL query. I'm providing this from the top of my head. It's possible I made a mistake.

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

  • Posts: 548
  • Thank you received: 11
  • Hikamarket Multivendor Hikashop Business
6 months 2 weeks ago #355815

how if want change by using import CSV file? what the column name to be use for the default variant. we don't want use query update from the database

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
6 months 2 weeks ago #355823

Hi,

You need to provide a CSV with 1 row for the main product and 1 row for each variant of the product.
In that CSV, you need the columns product_code, product_parent_id and the columns of the characteristics.
When you export the products data from the products listing, you'll get a CSV with all this already there.
So you need to change the value of the cell for the characteristics columns and the main product row to point at the new default values.

The following user(s) said Thank You: ler@singmuiheng.com

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

  • Posts: 548
  • Thank you received: 11
  • Hikamarket Multivendor Hikashop Business
6 months 2 weeks ago #355854

thank you, its working now. but there is setting need to change when import the CSV file the keep other variant must set to "No" only can work successfully.

The following user(s) said Thank You: nicolas

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

Time to create page: 0.061 seconds
Powered by Kunena Forum