variant related product

  • Posts: 20
  • Thank you received: 3
6 hours 19 minutes ago #371778

-- HikaShop version -- : 5.1.6
-- Joomla version -- : 5.2.2
-- PHP version -- : 8.2.20
-- Browser(s) name and version -- : chrome latest, firefox, etc.

Hi guys,

I have a question regarding product variants and related products functionality in HikaShop.

We are currently using HikaShop for an automotive parts webshop, and we have a specific use case that we are not sure how to properly implement with the default system.

Our structure:

We have products structured like this:

Product A: SKU 12312
contains 7 variants (e.g. Variant 1–7)
Product B: SKU 43234
also contains 7 corresponding variants (Variant 1–7)
Requirement:

We need to establish a relationship at variant level, not at product level.

For example:

Variant 5 of product 12312 (e.g. front left brakedisc)
should automatically be associated with
Variant 5 of product 43234 (e.g. front right brakedisc)

This pairing is consistent across all variants (1–7), meaning each variant index should map to the same index in the paired product.

Issue:

We noticed that HikaShop’s “related products” feature works only at product level and not at variant (child product) level. We also could not find a built-in way to assign related products individually per variant.

Question:

Is there any native way in HikaShop to:

assign related products per variant / characteristic value, or
implement variant-to-variant relationships between different parent products?

If not, could you recommend the best practice or extension approach for handling this kind of cross-product variant pairing?

We would like to avoid custom hacks if there is an intended or recommended solution.

Thank you very much for your help.

Best regards,
Zsolt

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

  • Posts: 85551
  • Thank you received: 14000
  • MODERATOR
2 hours 4 minutes ago #371781

Hi,

There are several things here:
- First, by default related products can't be configured per variant, only at the main product level.
- Second, when you change the selection of the variant on the frontend, the related products area is not refreshed.
- Third, the related products area under the product page is a listing of products, not a listing of variants. It is not made to be able to display variants.

Basically, the system is not meant to do what you want here and thus it won't be easy. If it were me, I would develop a custom plugin for this. It would:
- add an interface to select products on the variant edit form. This could potentially by made with a custom text field where you would just enter the code of the related variants separated with a comma.
- using the onHikashopBeforeDisplayView event ( www.hikashop.com/support/documentation/6...hopBeforeDisplayView ), check that we're on the frontend product details page, load the data of the variants of all the variants of the current product, return the HTML of all of them with only the default variant's listing visible by default + JS code implementing hkContentChanged ( www.hikashop.com/support/documentation/6...tml#hkContentChanged ) to change the visibility of the variants listing based on the selected variant.

With this, you have no custom hack, just a clean plugin implementing the events of HikaShop, so no surprises with updates.
However, it does require some development, several hundreds of lines of PHP to make that plugin.
If you have a proper setup, with a Claude Code or Codex, the AI can base itself on what I wrote here, plus the codebase of HikaShop and its plugins, to implement that plugin.

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

Time to create page: 0.053 seconds
Powered by Kunena Forum