1

I'm trying to hide out of stock products in layer navigation. This can be done using this code: http://colin.mollenhour.com/2009/07/14/hiding-out-of-stock-items-in-layered-navigation/

The issue is that the above code is not filtering out of stock for configurable products:
Suppose I have a configurable product based on size and all the simple for that size are are out of stock ... the product is not filtered ( as for Coling comment this is difficult to implement because of OO query implementation )

So I would like to use a not pure SQL approach removing products from collection "on the fly" (this is expensive in performance but let say I don't care) ...

... at this point the issue is that the toolbar is still showing all the products count ... any way to workarround this issue ?

Thanks

4
  • Have you found the solution of this? Thx.
    – Marvin3
    Apr 16, 2014 at 15:52
  • 1
    the best solution I could find is to filter the collection by entity_it NOT IN (ALL out of stock product ID )so toolbar works fine
    – Fra
    Apr 16, 2014 at 18:45
  • Can you please elaborate where exactly do you apply this filter, for some reason - it's not working on my side. Or please post code that you're using.
    – Marvin3
    Apr 16, 2014 at 20:48
  • This question is related to a problem with the toolbar ... from what I understand you are interested to the filter itself, that should be discussed in a different question.
    – Fra
    Apr 16, 2014 at 21:05

1 Answer 1

1

I cannot find a precise a solution for the toolbar problem unless changing and overriding many magento files (template/block mainly).

Finally I figured out that the best approach was to find the products that I want to exclude and add a filter to the main collection filtering them out, in this way the toolbar doesn't suffer any problem:

$collection->getSelect()
                ->where('e.entity_id NOT IN (?)', $remove_ids); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.