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

#   Hikashop default variant in database

##

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

Less More

- Posts: 2
- Thank you received: 0
-
-

2 years 2 months ago [\#362548](#362548) by [mydreams](/forum/user/27087-mydreams "View mydreams's Profile")  *[Hikashop default variant in database](/forum/37-import-export-csv-xls/908479-hikashop-default-variant-in-database#362548 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 7.2.24 -- Error-message(debug-mod must be tuned on) -- : Column is&#95;default is not found on table oah2p&#95;hikashop&#95;product  Hello,  I need some advice on where to find information in the database about whether the variant is the default or not. In the picture I marked what I mean. I need a SQL query that will return 1 if the variant is the default and 0 if the variant is not the default.  I can't find that information anywhere in the database, I have searched all the Hikashop database tables.  Thanks for advice very much.")* was created by *[mydreams](/forum/user/27087-mydreams "View mydreams's Profile")*

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 7.2.24
-- Error-message(debug-mod must be tuned on) -- : Column is_default is not found on table oah2p_hikashop_product

Hello,

I need some advice on where to find information in the database about whether the variant is the default or not. In the picture I marked what I mean.
I need a SQL query that will return 1 if the variant is the default and 0 if the variant is not the default.

I can't find that information anywhere in the database, I have searched all the Hikashop database tables.

Thanks for advice very much.

[ ![2024-08-0808&#95;04&#95;39-Sporttickettravel.cz-Administrace-Zbo.png](/forum/attachment/59592) ](/forum/attachment/59592 "...strace-Zbo.png")

- [ ![2024-08-0808&#95;04&#95;39-Sporttickettravel.cz-Administrace-Zbo.png](/forum/attachment/59592) ](/forum/attachment/59592 "...strace-Zbo.png") [ ](/forum/attachment/59592?download=1 "...strace-Zbo.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM3LWltcG9ydC1leHBvcnQtY3N2LXhscy85MDg0NzktaGlrYXNob3AtZGVmYXVsdC12YXJpYW50LWluLWRhdGFiYXNlP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

2 years 2 months ago [\#362552](#362552) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Hikashop default variant in database](/forum/37-import-export-csv-xls/908479-hikashop-default-variant-in-database#362552 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 7.2.24 -- Error-message(debug-mod must be tuned on) -- : Column is&#95;default is not found on table oah2p&#95;hikashop&#95;product  Hello,  I need some advice on where to find information in the database about whether the variant is the default or not. In the picture I marked what I mean. I need a SQL query that will return 1 if the variant is the default and 0 if the variant is not the default.  I can't find that information anywhere in the database, I have searched all the Hikashop database tables.  Thanks for advice very much.")*

Hi,

This will be difficult.
In the hikashop_variant table, you have, for each characteristic of a product, one entry linking the product in the hikashop_product table and the characteristic in the hikashop_characteristic table, and one entry linking the product and the default value of the characteristic for that product.
So once you know the characteristic_id of the default values of the product with one MySQL query, you can run a second MySQL query to look of the entry in hikashop_product with its product_parent_id equal to the product_id of the main product, and with an entry for each characteristic in the hikashop_variant table with a link to the characteristic_id of the default value.
Doing all this in a single MySQL query, while allowing for multiple characteristics per product and supporting many characteristics will be quite difficult. I don't know if it's even possible.
In HikaShop, we don't do that in MySQL. We load the variants of the product, we load the links of the variants to the characteristic values, we load the links of the main product to the entries in the hikashop_characteristic table, and we sort this in PHP in order to know the default variant.

The following user(s) said Thank You: [mydreams](/forum/user/27087-mydreams "View mydreams's Profile")

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

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

Less More

- Posts: 2
- Thank you received: 0
-
-

2 years 2 months ago -  2 years 2 months ago [\#362556](#362556) by [mydreams](/forum/user/27087-mydreams "View mydreams's Profile")  Replied by *[mydreams](/forum/user/27087-mydreams "View mydreams's Profile")* on topic *[Hikashop default variant in database](/forum/37-import-export-csv-xls/908479-hikashop-default-variant-in-database#362556 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 7.2.24 -- Error-message(debug-mod must be tuned on) -- : Column is&#95;default is not found on table oah2p&#95;hikashop&#95;product  Hello,  I need some advice on where to find information in the database about whether the variant is the default or not. In the picture I marked what I mean. I need a SQL query that will return 1 if the variant is the default and 0 if the variant is not the default.  I can't find that information anywhere in the database, I have searched all the Hikashop database tables.  Thanks for advice very much.")*

Thank you for your advice. Isn't it possible to get the SQL query and the additional PHP logic from the hikashop code somewhere?

I understand that it is not possible to get a list of all variants from the database itself or by using JOIN and whether the variant is the default or not?

This is bad:
Code:

v.is_default AS is_deafult -- this is bad

I have this SQL query:
Code:

SELECT p.product_id AS 'ID produktu', p.product_name AS 'název hlavního produktu', COALESCE(v.product_quantity, p.product_quantity) AS 'Počet', c.characteristic_id AS 'characteristic_id', c.characteristic_value AS 'název varianty', prc.price_product_id AS 'price_product_id', prc.price_id AS 'ID ceny', prc.price_value AS 'Cena', p.product_published AS 'published_hlavni', v.product_published AS 'published_varianta', v.product_id AS 'ID varianty', v.is_default AS is_deafult -- this is bad ----------------------------- FROM oah2p_hikashop_product AS p LEFT JOIN oah2p_hikashop_product AS v ON v.product_parent_id = p.product_id LEFT JOIN oah2p_hikashop_variant AS v_c ON v.product_id = v_c.variant_product_id LEFT JOIN oah2p_hikashop_characteristic AS c ON v_c.variant_characteristic_id = c.characteristic_id LEFT JOIN oah2p_hikashop_price AS prc ON prc.price_product_id = COALESCE(v.product_id, p.product_id) WHERE p.product_parent_id = 0 OR p.product_parent_id IS NULL ORDER BY p.product_id, v.product_id;

Last edit: 2 years 2 months ago by [mydreams](/forum/user/27087-mydreams "View mydreams's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM3LWltcG9ydC1leHBvcnQtY3N2LXhscy85MDg0NzktaGlrYXNob3AtZGVmYXVsdC12YXJpYW50LWluLWRhdGFiYXNlP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

2 years 2 months ago [\#362559](#362559) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Hikashop default variant in database](/forum/37-import-export-csv-xls/908479-hikashop-default-variant-in-database#362559 "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 7.2.24 -- Error-message(debug-mod must be tuned on) -- : Column is&#95;default is not found on table oah2p&#95;hikashop&#95;product  Hello,  I need some advice on where to find information in the database about whether the variant is the default or not. In the picture I marked what I mean. I need a SQL query that will return 1 if the variant is the default and 0 if the variant is not the default.  I can't find that information anywhere in the database, I have searched all the Hikashop database tables.  Thanks for advice very much.")*

Hi,

As I said, it's not just on MySQL query.
If you want to look at what we have to get the default variant, you have two places:
- in the backend variants listing we calculate the default variant with the code from the form_variants method of administrator/components/com_hikashop/views/product/view.html.php which loads the data, and the code in the administrator/components/com_hikashop/views/product/tmpl/form_variants.php which calculates the default variant while displaying the table list of variants.
- on the product page on the frontend, we load the variants and characteristics data in the show function of components/com_hikashop/views/product/view.html.php and we then call addCharacteristics of administrator/components/com_hikashop/classes/product.php to find the default variant, and order the characteristics and variants properly.

It's a lot of code, as we don't just want to know the default variant, but a whole bunch of other things.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM3LWltcG9ydC1leHBvcnQtY3N2LXhscy85MDg0NzktaGlrYXNob3AtZGVmYXVsdC12YXJpYW50LWluLWRhdGFiYXNlP3RtcGw9bWFya2Rvd24=) 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.124 seconds

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

[](#top)
