VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: atrus on April 16, 2013, 18:21:23 PM

Title: IMPROVEMENT - Search/Browse/Manufacturer Display of Parent Products only
Post by: atrus on April 16, 2013, 18:21:23 PM
A classic annoying issue when you have parents with many children products (which you want to be searchable, so the "Show uncategorised child products in search results and modules?" is ticked in VM2 Config), is that when the results appear the customer is truly lost, especially when children products have little difference between them, or share the same picture.

The solution is to keep the children product searchable, but display only the parent in the results (without ofcourse unticking "Show uncategorised child products in search results and modules?" because then the children products are not searchable)

Simply go in /administrator/components/com_virtuemart/models/product.php

and REPLACE

$select = ' l.`virtuemart_product_id` FROM `#__virtuemart_products_' . VMLANG . '` as l';

WITH

$select = ' DISTINCT IF(p.`product_parent_id` > 0, p.`product_parent_id`, l.`virtuemart_product_id`) FROM `#__virtuemart_products_' . VMLANG . '` as l';

also REPLACE

$select = ' p.`virtuemart_product_id` FROM `#__virtuemart_products` as p';

WITH

$select = ' DISTINCT IF(p.`product_parent_id` > 0, p.`product_parent_id`, p.`virtuemart_product_id`) FROM `#__virtuemart_products` as p';

That's it ;)

You can check the result here:

www.quality-tuning.co.uk

Rgrds,
Chris