superskyman100 Posted April 29, 2020 Share Posted April 29, 2020 Hi, I already searched around this forum + google but i have no solution. - Presta 1.7.6.4 - Faceted search 3.5.0 Problem : faceted search doesn't filter attribute stock = 0 - have XXL size for product P1,P2,..., Pn - P1 have stock = 0 for XXL size - in catalog, if i use the filter attribute 'size XXL' the result shows P1..... while P1 doesn't have any stock in XXL..... - the filter shouldn't show the product P1 with size XXL cause there is no stock with this attribute Any fix ? Thanks Link to comment Share on other sites More sharing options...
superskyman100 Posted April 30, 2020 Author Share Posted April 30, 2020 Anyone here ??? Link to comment Share on other sites More sharing options...
YiannisK Posted June 8, 2020 Share Posted June 8, 2020 Never-ending "filters" story. This is not solved since I can remember. I did solve it through some forum answers for 1.5 and 1.6 but I can't get it to work for 1.7 Most people ended up buying an expensive module. What was your solution? Link to comment Share on other sites More sharing options...
superskyman100 Posted June 8, 2020 Author Share Posted June 8, 2020 Ended up like you said... Buying one good module.... Easy Filters... https://www.sunnytoo.com/product/easy-filter-module-for-prestashop1-7 Link to comment Share on other sites More sharing options...
antoniocici Posted January 18, 2021 Share Posted January 18, 2021 (edited) After reading a lot of forum topics and GitHub Issues marked as "solved", but solved only for older versions of Prestashop and, mainly, for older versions of the Faceted Search Module, I've found a solution, that works well form me. Since all the queries have been replaced by calls to Search Adapter Objects, I've modified the file: /modules/ps_facetedsearch/src/Product/Search.php at line 147, modifying the source code from this: case 'id_attribute_group': $operationsFilter = []; foreach ($filterValues as $attributeId => $filterValue) { $this->getSearchAdapter()->addOperationsFilter( 'with_attributes_' . $attributeId, [[['id_attribute', $filterValue]]] ); } break; to this: case 'id_attribute_group': $operationsFilter = []; foreach ($filterValues as $attributeId => $filterValue) { $this->getSearchAdapter()->addOperationsFilter( 'with_attributes_' . $attributeId, [[['id_attribute', $filterValue]]] ); } //modded by Antonio to hide Out of Stock combinations $operationsFilter = []; $operationsFilter[] = [ ['quantity', [0], '>'], ]; $this->getSearchAdapter()->addOperationsFilter( self::STOCK_MANAGEMENT_FILTER, $operationsFilter ); break; and finally it works! Edited January 18, 2021 by antoniocici (see edit history) 6 4 Link to comment Share on other sites More sharing options...
YiannisK Posted January 18, 2021 Share Posted January 18, 2021 (edited) Tried one more time with a fresh copy of facet module and it worked! Thanks @antoniocici! I really don't understand why the PrestaShop team does not include this to the core. This is a great solution.. Edited January 19, 2021 by YiannisK (see edit history) Link to comment Share on other sites More sharing options...
afshop Posted January 22, 2021 Share Posted January 22, 2021 On 1/18/2021 at 12:28 PM, antoniocici said: After reading a lot of forum topics and GitHub Issues marked as "solved", but solved only for older versions of Prestashop and, mainly, for older versions of the Faceted Search Module, I've found a solution, that works well form me. Since all the queries have been replaced by calls to Search Adapter Objects, I've modified the file: /modules/ps_facetedsearch/src/Product/Search.php at line 147, modifying the source code from this: case 'id_attribute_group': $operationsFilter = []; foreach ($filterValues as $attributeId => $filterValue) { $this->getSearchAdapter()->addOperationsFilter( 'with_attributes_' . $attributeId, [[['id_attribute', $filterValue]]] ); } break; to this: case 'id_attribute_group': $operationsFilter = []; foreach ($filterValues as $attributeId => $filterValue) { $this->getSearchAdapter()->addOperationsFilter( 'with_attributes_' . $attributeId, [[['id_attribute', $filterValue]]] ); } //modded by Antonio to hide Out of Stock combinations $operationsFilter = []; $operationsFilter[] = [ ['quantity', [0], '>'], ]; $this->getSearchAdapter()->addOperationsFilter( self::STOCK_MANAGEMENT_FILTER, $operationsFilter ); break; and finally it works! Great!!!! Many thanks Angela Link to comment Share on other sites More sharing options...
sandrineparent Posted February 11, 2021 Share Posted February 11, 2021 Hi, It's worked for the product lists. But not in the number of available products. For example, in the filter, I have Size 39 (5). And below, I have 4 products because really I have 4 products available in this size. An idea to change that? I mean to have 39 (4)... Thanks Sandrine 1 Link to comment Share on other sites More sharing options...
Tárraga Posted May 20, 2022 Share Posted May 20, 2022 On 2/11/2021 at 5:48 PM, sandrineparent said: Hi, It's worked for the product lists. But not in the number of available products. For example, in the filter, I have Size 39 (5). And below, I have 4 products because really I have 4 products available in this size. An idea to change that? I mean to have 39 (4)... Thanks Sandrine @antoniocici Any idea for that? Link to comment Share on other sites More sharing options...
koniofix Posted September 17, 2022 Share Posted September 17, 2022 Same issue for me. Works perfectly at products list but I had to switch off the counting of products on the left side because numbers are wrong. Link to comment Share on other sites More sharing options...
Un_Tal_Iban Posted October 3, 2022 Share Posted October 3, 2022 (edited) It works very well, it is appreciated, but if the product has the option to allow purchase without stock, these products are not shown in the results when they can actually be purchased, and should appear. Edited October 3, 2022 by Un_Tal_Iban (see edit history) Link to comment Share on other sites More sharing options...
Mickael Posted December 7, 2023 Share Posted December 7, 2023 La solution proposée ne tient pas compte de la notion out_of_stock du produit. Il faudrait je pense : $operationsFilter = []; $operationsFilter[] = [ ['quantity', [0], '<='], ['out_of_stock', !$this->psOrderOutOfStock ? [0, 2] : [0], '='], ]; $operationsFilter[] = [ ['quantity', [0], '>'], ]; $this->getSearchAdapter()->addOperationsFilter( self::STOCK_MANAGEMENT_FILTER, $operationsFilter ); et pour la partie block, il suffit de faire la même chose dans src/Filters/Block.php [591] et ensuite de vider le cache du module. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now