- Posts: 171
- Thank you received: 9
Related products on product page
- pepecortez
-
Topic Author
- Offline
-- Joomla version -- : 4.1.5
-- PHP version -- : 7.4
Hi there!
I wanna ask for some trick to solve my needs:
I successfully set up to show some random items on my product's page, but I'm unable to set it up to get these not randomly but maybe much more related to the actual item "automatically" - as there are thousands of items in the shop imported, setting up manually every item's related products is not an option.
I thought on based on the product's page product name maybe stripping long product names to separate words, and run on these a LIKE SQL query, but any idea/alternatives is appreciated.
Thanks in advance,
PePe
Please Log in or Create an account to join the conversation.
I don't see a way to do that with just the options available by default.
What you could do is develop a small plugin implementing the onBeforeProductListingLoad event to add conditions to the MySQL query loading the products when on the product details page:
www.hikashop.com/support/documentation/6...reProductListingLoad
So if you have PHP knowledge, you can do that.
This plugin would be a good basis as it uses the same event:
www.hikashop.com/marketplace/product/222...-product-plugin.html
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
nicolas wrote: Hi,
I don't see a way to do that with just the options available by default.
What you could do is develop a small plugin implementing the onBeforeProductListingLoad event to add conditions to the MySQL query loading the products when on the product details page:
www.hikashop.com/support/documentation/6...reProductListingLoad
So if you have PHP knowledge, you can do that.
This plugin would be a good basis as it uses the same event:
www.hikashop.com/marketplace/product/222...-product-plugin.html
Thanks Nicolas!
By your links I've finally made a small plugin, it seems working, would u be so kind, to check it over to be perfect, and maybe easily adopted by anyone who needs that?
Please Log in or Create an account to join the conversation.
That's indeed quite nice ! Thanks for sharing.
I would add that line:
Also, there is a potential issue for others:
if they have several products listing modules on the product page, that plugin would add the condition on all the modules. If you want it only for one of them, it would require for example a static variable to add the condition only the first time, or only the second time or etc based on which module should receive the condition.
Please Log in or Create an account to join the conversation.