Hi,
You need three things to add variants to a product:
- add the variants entries in the hikashop_table. I can see this is done with your second INSERT query
- add entries in the hikashop_variant table linking the default values in hikahop_characteristic and the main product entry in hikashop_product. I can see this is done with your first INSERT query.
- add entries in the hikashop_variant table linking each variant in hikashop_product to their corresponding values in hikashop_characteristic. I don't see this query in your txt file.
So I suppose you're missing the third query and that's why it behaves incorrectly.
Note that the goal of variants is to allow the customer to select several values on the product page so that they can choose among several variants of the same product, and based on what is selected the price/stock/image/etc can be different.
That's what is shown here:
demo.hikashop.com/index.php/en/hikashop/...with-characteristics
I can see that you only have one variant for each product which means the selection on the product page is meaningless.
In that case, I would recommend to use custom fields of the table "product" instead of characteristics, like we did with the "specifications" page here:
demo.hikashop.com/index.php/en/hikashop/.../with-specifications
A custom field of the table "product" will add a corresponding column in the hikashop_product table.
You can use the type "single dropdown" so that in the custom field "values" section, you can enter the different values allowed.
And then in each product you can select the value you want in the custom field.
And you can link a filter to that custom field so that it will use the values of the custom field to filter the product.
Another nice thing if doing it like that is that you can easily set the value of the custom field for a bunch of products with a simple query:
UPDATE #__hikashop_product SET xxx = 'yyy' WHERE product_name LIKE "%i5%";
where xxx is the column name of the custom field and yyy the value you want to set.
In fact, these can easily be done via the interface in the backend for people who don't know MySQL :
- create a new mass action in the System>Mass actions menu
- add a filter on the product_name with the mode "like" selected and the value %i5%
- add an action "update the values" on the product_name column with the mode "string" and yyy in the input field.
- when you press "process", it will run the mass action and basically run the UPDATE query for you.
Having custom product fields instead of characteristics will also be less resource-hungry when using filters, and will allow things like add to cart from the products listings (which is not possible for products with variants).