2

I need is_in_stock to be exposed as an attribute for which I can set "Use in layered navigation" to "Filterable (with results".

I can't seem to find a way to do this? I can't find an extension which does this? Does anyone have any ideas?

To clarify: I'm using ElasticSearch as my search backend, and ElasticSearch takes over layered navigation by using it's own facets which mirror the attribute settings for Layered Navigation - so that's why I need a stock attribute.

6
  • Bad (but easy) idea: create attribute, sync it with the stock status. Commented Mar 27, 2015 at 10:55
  • Thanks - Would you mind elaborating? Creating a attribute is easy enough but how would I go about 'syncing with the stock status' ?
    – Mark B
    Commented Mar 27, 2015 at 11:06
  • You have to register a observer on every event which might change the stock status and update your attribute. And be careful this can be a performance killer. Commented Mar 27, 2015 at 11:08
  • 1
    Thanks to Fabian Blechschmidt, I got an idea. I'm checking stock levels on my import script and assigning an 'in stock' or 'out of stock' value to an attribute which I apply to all products
    – Mark B
    Commented Apr 1, 2015 at 10:47
  • You are welcome to answer your own questions :-) Commented Apr 1, 2015 at 12:38

1 Answer 1

2

You can create a new attribute, name it e.g. is_in_stock and sync it with the stock status.

Depending on the way you import products, you need to hook into:

  • importing products
  • saving products (in backend)
  • buying products
  • returning products/canceling orders/...

Then you can just use the attribute.

Not sure whether this is a good idea, especially because it might cost a lot of performance.

The (better?) alternative is to implement your own layer model and block to do what you want.

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.