Multiple Specifications as Filters

Phoca Cart - complex e-commerce extension
itn-ms
Phoca Member
Phoca Member
Posts: 20
Joined: 04 Apr 2025, 11:58

Re: Multiple Specifications as Filters

Post by itn-ms »

Hi Jan,

the Search And Filter Options are also at their default.
I changed the filter options for specifications from any to all:
https://i.imgur.com/a/bxByfln
So the behaviour I would expect (and need) for example in your case is, that the Coat is not shown because it is not blue. The Cleaner should only be shown if it is blue AND the packaging convenient. If I have no products that fulfill every filter criteria, no product should be shown.

When I leave the filter options to Any, everything works as expected, as I get more and more products the more filters I activate - but I want the opposite behaviour; which I thought must be the option all, which is not working as expected for me. :idea:

Kind regards,
Marco
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48763
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Multiple Specifications as Filters

Post by Jan »

Hi, thank you very much for the detailed info, now I understand and seems I found the problem, if you are able to edit files on your server, go to:
administrator/components/com_phocacart/libraries/phocacart/search/search.php

and on line cca 441 change

FROM:

Code: Select all

if (I18nHelper::isI18n()) {
    $where .= " INNER JOIN #__phocacart_specifications AS s2bx" . $i . " ON s2x" . $i . ".product_id = s2x" . $i . ".product_id AND " . $v;
} else {
    $where .= " INNER JOIN #__phocacart_specifications AS s2x".$i." ON s2x" . $i . ".product_id = s2x".$i.".product_id AND ". $v;
}
TO:

Code: Select all

if (I18nHelper::isI18n()) {
    $where .= " INNER JOIN #__phocacart_specifications AS s2bx" . $i . " ON s2x0.product_id = s2x" . $i . ".product_id AND " . $v;
} else {
    $where .= " INNER JOIN #__phocacart_specifications AS s2x".$i." ON s2x0.product_id = s2x".$i.".product_id AND ". $v;
}
This should solve the problem with "All" - only items which will have all selected parameters will be displayed.

Let me know if this works for you.

Jan
If you find Phoca extensions useful, please support the project
itn-ms
Phoca Member
Phoca Member
Posts: 20
Joined: 04 Apr 2025, 11:58

Re: Multiple Specifications as Filters

Post by itn-ms »

Hi Jan,

thanks for your efforts!

I replaced the mentioned code - now it partly works:
The items are filtered so only products where all filters are true are shown but there's still the issue, that only the last filter of the URL is used.
In my test-site I checked Packaging = Eco, Color = Blue and Flavour = Apple, Pear - only the Flavour-filters are used, also shown in the resulting sql:

Code: Select all

 .. AND a.id IN (
    SELECT 
      s2x0.product_id 
    FROM 
      b2h05_phocacart_specifications AS s2x0 
      INNER JOIN b2h05_phocacart_specifications AS s2x1 ON s2x0.product_id = s2x1.product_id 
      AND s2x1.alias = 'flavour' 
      AND s2x1.alias_value = "pear" 
    WHERE 
      s2x0.alias = 'flavour' 
      AND s2x0.alias_value = "apple"
  ) 
GROUP BY.. 
The filters in the URL are:
https://imgur.com/a/DjfOEHL

The filtered products for the flavour are now after the code change correct :)

Kind regards,
Marco
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48763
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Multiple Specifications as Filters

Post by Jan »

Hi,

try to reinstall with 5.1.1Beta2:
https://github.com/PhocaCz/PhocaCart/re ... 1Beta2.zip

and let me know.

Jan
If you find Phoca extensions useful, please support the project
Post Reply