Hi,
The thing is that the variants data of each product is not loaded on the products listings.
We avoid doing that as it would make the page processing crash on a lot of websites.
Suppose that you have 100 variants for each product. That's already a lot but it's manageable on the product page.
But if you display a products listing and need to load the data of all the variants of all the products, even with only 20 products on your listing, that's already 2020 product entities loaded and processed.
That's just too much data for the resources restrictions in place on normal hostings.
So that will make your job more difficult as you first need to load the variants data to know which variant is the default one and then load its price.
You want to edit the getListingPrices function of the file administrator/components/com_hikashop/classes/currency.php
There, you'll find two main blocks of code. The first one load the prices of the main product and get the cheapest/unit/range one(s). The second load load the prices of the variants of the product and get the cheapest/unit/range one(s).
So in between these two blocks, right after the line
if(!empty($variantSearch)){
you want to:
- first to do a MySQL query in the hikashop_variant table in order to get the characteristic_ids linked to the main products product_id.
- second, to do a MySQL query in the hikashop_product table in order to load the product_ids of all the variants of the main products based on the product_parent_id being equal to the product_id of the main products
- third, to do a MySQL query in the hiakshop_variant table in order to get the entries matching the characteristic_ids of your first query with the product_ids of your second query. That will give you the product_ids of the default variants of the main products
- fourth, to do a MySQL query in the hikashop_price table in order to load the prices of these default variants based on their product_ids
- fifth, to do the same PHP processing on them and get the cheapest/unit/range one(s).
So it's not just a few lines of code to add and will make the loading of the page a bit slower. That's why we decided not to do it by default and use the trick of providing the price for the listing in the main product instead.