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:
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;