Magento2: Magento2 Layered Navigation Filter Configurable Product Out of Stock

Created on 17 Jan 2017  路  29Comments  路  Source: magento/magento2

I am currently using Magento 2.1.3 CE for one of my projects, and I am facing an issue regarding the configurable product out of stock when filtered by configurable attribute (in make case size attribute) using layered navigation.

Preconditions

Project Environment

Magento Version: 2.1.3 CE
PHP: 7.0.14
Database: MySQL 5.6
OS: CentOS 7
Caching: Varnish Cache and OPcache

Magento Settings

Show out of Stock Products: No
Backorder: No

Steps to reproduce

  1. Create configurable products (_for example: Shoes_)
  2. Create Category
  3. Enable layered navigation for the category
  4. Assign product to category
  5. Create linked simple products for sizes (_sizes 5.5, 6, 6.5, 7 and so on_)
  6. Set any one of the size (_lets say 5.5_) to out of stock, others are in-stock
  7. Set Show out of Stock Products: No
  8. Set Backorder: No
  9. Enable Flat Tables
  10. Run full indexing, flush cache and static content deploy etc.
  11. Navigate to category view page on Front end end
  12. Use layered navigation to filter by size attribute choose (5.5 or the size which was set to out of stock)
  13. The product will be shown even when the filtered by size attribute is out of stock

Expected Result

Although configurable products are considered out of stock only when all the simple products linked to configurable attribute are Out of Stock, it should consider the condition that when product listing page is filtered by a particular attribute value and the admin setting dictates that Out of stock product should not be shown, then in such cases it should do a stock check against the particular filtered value with the product's configurable attribute instead of checking the stocks of all the simple products linked to it.

Actual Result

Shows the product in the filtered listing page even when the attribute value used to filter the product is Out Of Stock

Can anyone help me out on this ?

Catalog Format is valid Ready for Work bug report

Most helpful comment

After updating to 2.1.8 this issue is not fixed for me.
In fact all layered navigation filters result in zero matches.

The empty results are fixed with this commit:
https://github.com/magento/magento2/commit/2c62aa376eeed447e632aedb42085c9d255520df

The issue with out of stock items is NOT fixed in 2.1.8

All 29 comments

Hello Team,

Did anyone get the chance to review on this issue ?

Hi,

The same issue we are facing in Magneto Community 2.1.3 .
Please check the link https://github.com/magento/magento2/issues/7964

Hello Team,

Any updates on this issue ?

Regards,
Atish

Hi,

This is known issue. We've already fixed this one for the develop branch in another ticket: https://github.com/magento/magento2/search?q=MAGETWO-59088&type=Commits&utf8=%E2%9C%93
Specifically for 2.1.x there is internal ticket MAGETWO-57475 which is not ready yet.

@igrybkov thanks for the update. Which release will this fix be in ?

@atishgoswami the fix will definetly get into 2.2 (next major product release), there is also a possibility that fix would be back ported to some of 2.1.* releases. The problem why it's not back ported yet is the fix implemented for 2.2 is not backward compatible (database structure has been changed), but according to our policies we could provide just PATCH releases for 2.0.* and 2.1.* which must be backward compatible

Same issue here. Using 2.1.3. @igrybkov when do you expect to have it?

@maghamed I have a Magento 2.1.5 merchant experiencing this issue and a patch for 2.1.x would be very much appreciated. Any idea when this patch could be created?

We resolve it disabling all product when became out of stock and re-enabling when turn in stok. This solution give some problem if you want out of stock size in product view, but resolve temporally out of stok filter.
If someone need we are releasing an observer model that enable and disable automatically product when go out of stock or return in stock.

https://github.com/Cooder08/StockProductStatus

Hi,
As I see, the fix has been delivered to 2.1.8.
Please check it.

After updating to 2.1.8 this issue is not fixed for me.
In fact all layered navigation filters result in zero matches.

The empty results are fixed with this commit:
https://github.com/magento/magento2/commit/2c62aa376eeed447e632aedb42085c9d255520df

The issue with out of stock items is NOT fixed in 2.1.8

@igrybkov why do you say that - neither MAGETWO-57475 nor MAGETWO-59088 are mentioned in 2.1.8 release notes - which commit is this fixed in?

Hi, i have the same issue any workaround until the fix will be include in the next releases?

I can also confirm the issue still exists in 2.1.9 please can somebody supply a commit ref which contains the fix?

It works perfect in 2.2
I doubt there will be a fix for 2.1 branch

Hi,
@maaarghk, I see these changes were merged in commit e4e4c6db4487314a22c17006009205943492e5ce.

Also, these changes are present in the 2.1.9 tag: https://github.com/magento/magento2/blob/479f137cf47f6907aa5061b36b183295387c0968/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php#L274-L278

I've checked the issue on 2.1.9 and cannot reproduce it.
Please note that the fix is for MySQL search adapter. Which search engine do you use?

We have problems with 10.1.28-MariaDB and percona 5.6.36-82.0

I am using mysql 5.7.20 and magento 2.1.9
https://i.imgur.com/G9S7br9.png

still not working for me

hi. Any workaround on 2.1.x?
Same issue here on 2.1.8.

Hi @yosefkurniawan,
I had reported to magento enterprise portal, go this patch from them, never got a chance to check if it works as my Project got upgraded to 2.2.x.

Here's the patch:
MDVA-2969_EE_2.1.0_v2_composer.patch.gz

Let me know if it worked.

Hi there, I am having the same issue and I'm on 2.2.2. Does anyone know the fix for it?

Hi @miteedesign.

Provide please:
Database
PHP
OS
Magento edition - CE or EE
Indexer Mode - Update on Save or Update by Schedule
Attribute Catalog Input Type for Store Owner - Dropdown, Visual Swatch, Text Swatch
Attribute Use in Layered Navigation - Filterable (with results), Filterable (no results)
Configuration Display Out of Stock Products - Yes or No
Any other changed options.

Or just create a screencast with all preconditions and steps.

Thank You.

Hi,
The issue is still there with Cloud version 2.1.9. Did not get any update on this specific error !! Its horrible experience.
Thanks,
Dan

@lewis-dan can you try applying the patch attached
https://github.com/magento/magento2/files/1710709/MDVA-2969_EE_2.1.0_v2_composer.patch.gz
and see if it works

@atishgoswami I tried to implement the same patch with 2.1.9, however, getting the following errors -

W: error: patch failed: vendor/magento/module-catalog-inventory/Model/Stock/StockItemRepository.php:167
W: error: vendor/magento/module-catalog-inventory/Model/Stock/StockItemRepository.php: patch does not apply
W: error: patch failed: vendor/magento/module-configurable-product/Block/Product/View/Type/Configurable.php:129
W: error: vendor/magento/module-configurable-product/Block/Product/View/Type/Configurable.php: patch does not apply
W: error: patch failed: vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php:8
W: error: vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php: patch does not apply
W: error: patch failed: vendor/magento/module-configurable-product/Test/Unit/Model/Product/Type/ConfigurableTest.php:11
W: error: vendor/magento/module-configurable-product/Test/Unit/Model/Product/Type/ConfigurableTest.php: patch does not apply
W: error: patch failed: vendor/magento/module-swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php:154
W: error: vendor/magento/module-swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php: patch does not apply
W: error: patch failed: vendor/magento/module-swatches/Test/Unit/Block/Product/Renderer/Listing/ConfigurableTest.php:179
W: error: vendor/magento/module-swatches/Test/Unit/Block/Product/Renderer/Listing/ConfigurableTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php:75
W: error: dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/Export/RowCustomizerTest.php:5
W: error: dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/Export/RowCustomizerTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php:5
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php:5
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php:9
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php:19
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php:11
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/VariationHandlerTest.php:9
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/VariationHandlerTest.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php:3
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php:99
W: error: dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php: patch does not apply
W: error: patch failed: dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/quote_with_configurable_product.php:4

@igrybkov I checked your points, however, that solution is also NOT working !!

Hi,
Still we have the same issue with Magento Cloud edition 2.1.9. Please suggest me any solution which will work.
Thank you in advance for your cooperation.
Thanks,
Dan

any updates on this issue? I am still experiencing this in 2.3.5-p2.

Is this issue being worked on? Any updates form @magento-admin

Was this page helpful?
0 / 5 - 0 ratings