- Posts: 575
- Thank you received: 11
Import Product With CSV - can change variants default to another variants?
- ler@singmuiheng.com
-
Topic Author
- Offline
Less
More
2 years 11 months ago #355651
by ler@singmuiheng.com
Import Product With CSV - can change variants default to another variants? was created by ler@singmuiheng.com
-- 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?
-- 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.
2 years 11 months ago #355655
by nicolas
Replied by nicolas on topic Import Product With CSV - can change variants default to another variants?
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:
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.
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:
Code:
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
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.
- ler@singmuiheng.com
-
Topic Author
- Offline
Less
More
- Posts: 575
- Thank you received: 11
2 years 11 months ago #355815
by ler@singmuiheng.com
Replied by ler@singmuiheng.com on topic Import Product With CSV - can change variants default to another variants?
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.
2 years 11 months ago #355823
by nicolas
Replied by nicolas on topic Import Product With CSV - can change variants default to another variants?
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.
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.
- ler@singmuiheng.com
-
Topic Author
- Offline
Less
More
- Posts: 575
- Thank you received: 11
2 years 11 months ago #355854
by ler@singmuiheng.com
Replied by ler@singmuiheng.com on topic Import Product With CSV - can change variants default to another variants?
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.226 seconds