[resolved] Product_id in database is deleted when adding variants

  • Posts: 20
  • Thank you received: 0
  • Hikashop Business
2 years 1 month ago #317696

-- HikaShop version -- : 4.2.3
-- Joomla version -- : 3.9.16

Hi,
it seems the product_id may be deleted from database (table hikashop_product) when creating variants for the first time.

I used to work with a "basic" product (no variants) which had the product_id 5622.
It was already used in some orders (example for me in order 5608)

Then I created some variants on this product, which resulted (in the product table) to the deletion of this line, and the creation of multiple lines with new ids (for example product_id 6015)

My problem is as following :
When querying the database and JOINing tables order_product and product, there is no match anymore because product_id '5622' is not anymore in table product.

It's like I have a "mystery" product in these orders and I can't display its name in my SQL extract.

=> could you find a way to improve it and maybe have a logical deletion instead of a hard one ?
or maybe I missed something when creating the variants...

thanks
JB


-Hikashop 2.3.0-

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

  • Posts: 75528
  • Thank you received: 11765
  • MODERATOR
2 years 1 month ago #317707

Hi,

You're missing something yes.
The product_id you had before for the main product is not deleted.
But yes, a product_id is added, one for each variant.
And what is referenced in the hikashop_order_product table's product_id column is the product_id of the variant of the product.
But fear not, in the hikashop_product, you have the product_parent_id column which points to the product_id of the main product of the variant.
So if you want to write a MySQL query where you have a condition on the product_id, it's totally possible. You just need to make your query a bit more complex by adding a join on the hikashop_product table to take into account the product_parent_id.

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

  • Posts: 20
  • Thank you received: 0
  • Hikashop Business
2 years 1 month ago #317714

Thanks a lot.
I will try that


-Hikashop 2.3.0-

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

  • Posts: 20
  • Thank you received: 0
  • Hikashop Business
2 years 1 month ago #317929

Apparently, my issue was not related to variants : my brother probably hard deleted the main product before creating a new one. No way to keep the link in that case :(
sorry for the misunderstanding

thanks anyway


-Hikashop 2.3.0-

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

Time to create page: 0.059 seconds
Powered by Kunena Forum