Subject: Attributes Osclass Plugin – search filter is silently ignored in subcategories when the attribute is assigned to the parent category only (reproducible on your demo site)
Hello,
I am using Attributes Osclass Plugin 2.9.0 and found an inconsistency between the search form and the search query: an attribute filter is shown in a subcategory's sidebar, but the selected value is not applied to the results.
Steps to reproduce (your demo site)
1- Open the parent category:
https://plugins2.abprofitrade.eu/for-sale The "Year" attribute filter is shown. Use the search URL with a range value:
index.php?page=search&sCategory=for-sale&atr_296_from=1 → 1 listing
index.php?page=search&sCategory=for-sale&atr_296_from=3000 → no results (correct, the filter works)
2- Open a subcategory, for example computers-hardware or electronics. The same "Year" filter is displayed in the sidebar. Use the same values:
index.php?page=search&sCategory=computers-hardware&atr_296_from=1 → 135 listings
index.php?page=search&sCategory=computers-hardware&atr_296_from=3000 → 135 listings (expected: no results)
Same behaviour for electronics: 134 listings for both values.
The filter value has no effect at all in the subcategory; the result list is identical to the unfiltered one. The same happens with other attribute types on my own installation (a SELECT attribute assigned to the parent category: filtering works in the parent category, but is ignored in its subcategories). There are no errors; the filter is just skipped silently.
Cause (from reading the code)
The two parts of the plugin use different category rules:
The search form, ModelATR::getSearchAttributes2(), uses Category::toRootTree(), so an attribute assigned to the root/parent category is displayed in all of its subcategories.
The search query, atr_search_extend() in functions.php, only applies the filter if the searched category ID is exactly in the attribute's s_category_id list (in_array($c_id, $atr_cats)). The parent categories are not considered, so $cat_ok stays false and the condition is skipped.
So an attribute that is assigned only to a parent category appears in the subcategory filter, but its value is ignored when searching.
Expected behaviour
If the filter is shown in a subcategory, it should also be applied there. For example, atr_search_extend() could use the same parent-category rule as getSearchAttributes2() (root tree) when checking whether the attribute is enabled for the searched category.
Could you please confirm this and let me know if it can be fixed in an official update?
Thank you.