VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: EvanGR on August 19, 2020, 09:43:09 AM

Title: Creating dynamic / AJAX related products.
Post by: EvanGR on August 19, 2020, 09:43:09 AM
Up till now, the related products (single product page), have been manually pre-configured for each product, which is the VM default way of doing things.

We now want a better solution, something like this:

1) Related products are loaded dynamically, based on a search query, each time a product is viewed.
2) The results are fetched via an AJAX call, so the core product page loads fast.

This has multiple advantages, especially as new products are inserted, the old ones can still point to the newer ones as related, without any manual editing.
It's easier to make changes to the related search query.
Also, it should be faster to the user, due to the asynchronous AJAX call... and the ability to dynamically configure how many related products to fetch.

We need to be able to define our own search query for fetching related products (our products have custom fields for this purpose).

My question:
Is there an extension that will allow us to do the above?

If not, we want to build our custom solution. We need some advice, what VM files to look into, to get started:

1) How/where would we look to define a search query, and get back related products (that match specific custom fields)?

2) If we wanted to do it via an AJAX call, is there any reference code we can look at?

Thanks