[Skip to main content](#vessel-content)

#   \[resolved\] Product\_id in database is deleted when adding variants

##

- **[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")**
- [![jbvieren's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30535-jbvieren "View jbvieren's Profile") Topic Author
- [ Offline](/forum/user/30535-jbvieren)

Less More

- Posts: 26
- Thank you received: 0
-
-

6 years 6 months ago [\#317696](#317696) by [jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")  *[Product\_id in database is deleted when adding variants](/forum/32-content-creation/899598-resolved-product-id-in-database-is-deleted-when-adding-variants#317696 "-- HikaShop version -- : 4.2.3 -- Joomla version -- : 3.9.16  Hi, it seems the product&#95;id may be deleted from database (table hikashop&#95;product) when creating variants for the first time.  I used to work with a &quot;basic&quot; product (no variants) which had the product&#95;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&#95;id 6015)  My problem is as following : When querying the database and JOINing tables order&#95;product and product, there is no match anymore because product&#95;id '5622' is not anymore in table product.  It's like I have a &quot;mystery&quot; product in these orders and I can't display its name in my SQL extract.  =&gt; 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")* was created by *[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")*

-- 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.

=&gt; 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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODk5NTk4LXJlc29sdmVkLXByb2R1Y3QtaWQtaW4tZGF0YWJhc2UtaXMtZGVsZXRlZC13aGVuLWFkZGluZy12YXJpYW50cz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14293
-
-

6 years 6 months ago [\#317707](#317707) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product\_id in database is deleted when adding variants](/forum/32-content-creation/899598-resolved-product-id-in-database-is-deleted-when-adding-variants#317707 "-- HikaShop version -- : 4.2.3 -- Joomla version -- : 3.9.16  Hi, it seems the product&#95;id may be deleted from database (table hikashop&#95;product) when creating variants for the first time.  I used to work with a &quot;basic&quot; product (no variants) which had the product&#95;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&#95;id 6015)  My problem is as following : When querying the database and JOINing tables order&#95;product and product, there is no match anymore because product&#95;id '5622' is not anymore in table product.  It's like I have a &quot;mystery&quot; product in these orders and I can't display its name in my SQL extract.  =&gt; 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")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODk5NTk4LXJlc29sdmVkLXByb2R1Y3QtaWQtaW4tZGF0YWJhc2UtaXMtZGVsZXRlZC13aGVuLWFkZGluZy12YXJpYW50cz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")**
- [![jbvieren's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30535-jbvieren "View jbvieren's Profile") Topic Author
- [ Offline](/forum/user/30535-jbvieren)

Less More

- Posts: 26
- Thank you received: 0
-
-

6 years 6 months ago [\#317714](#317714) by [jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")  Replied by *[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")* on topic *[Product\_id in database is deleted when adding variants](/forum/32-content-creation/899598-resolved-product-id-in-database-is-deleted-when-adding-variants#317714 "-- HikaShop version -- : 4.2.3 -- Joomla version -- : 3.9.16  Hi, it seems the product&#95;id may be deleted from database (table hikashop&#95;product) when creating variants for the first time.  I used to work with a &quot;basic&quot; product (no variants) which had the product&#95;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&#95;id 6015)  My problem is as following : When querying the database and JOINing tables order&#95;product and product, there is no match anymore because product&#95;id '5622' is not anymore in table product.  It's like I have a &quot;mystery&quot; product in these orders and I can't display its name in my SQL extract.  =&gt; 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")*

Thanks a lot.
I will try that

---

-Hikashop 2.3.0-

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODk5NTk4LXJlc29sdmVkLXByb2R1Y3QtaWQtaW4tZGF0YWJhc2UtaXMtZGVsZXRlZC13aGVuLWFkZGluZy12YXJpYW50cz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")**
- [![jbvieren's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30535-jbvieren "View jbvieren's Profile") Topic Author
- [ Offline](/forum/user/30535-jbvieren)

Less More

- Posts: 26
- Thank you received: 0
-
-

6 years 6 months ago [\#317929](#317929) by [jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")  Replied by *[jbvieren](/forum/user/30535-jbvieren "View jbvieren's Profile")* on topic *[\[resolved\] Product\_id in database is deleted when adding variants](/forum/32-content-creation/899598-resolved-product-id-in-database-is-deleted-when-adding-variants#317929 "-- HikaShop version -- : 4.2.3 -- Joomla version -- : 3.9.16  Hi, it seems the product&#95;id may be deleted from database (table hikashop&#95;product) when creating variants for the first time.  I used to work with a &quot;basic&quot; product (no variants) which had the product&#95;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&#95;id 6015)  My problem is as following : When querying the database and JOINing tables order&#95;product and product, there is no match anymore because product&#95;id '5622' is not anymore in table product.  It's like I have a &quot;mystery&quot; product in these orders and I can't display its name in my SQL extract.  =&gt; 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")*

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 ![:(](/media/kunena/emoticons/22.png ":(")
sorry for the misunderstanding

thanks anyway

---

-Hikashop 2.3.0-

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODk5NTk4LXJlc29sdmVkLXByb2R1Y3QtaWQtaW4tZGF0YWJhc2UtaXMtZGVsZXRlZC13aGVuLWFkZGluZy12YXJpYW50cz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.052 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
