magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.44k stars 9.29k forks source link

Magento 2.4.5: Show Out Of Stock option outputs all available products during search #36055

Closed pmonosolo closed 1 year ago

pmonosolo commented 1 year ago

Preconditions and environment

On website I'm working on to upgrade to 2.4.5 from 2.4.3, the Catalog Search ouputs the whole Enabled Catalog:

image

Instead of only ouputting the search results which should be 664 items:

image

Sorry bad screenshots because I was pulling the store apart to try to understand where it's coming from.

This can sort of be replicated on Vanilla Magento 2.4.5 with test data.

Here are the settings:

Catalog - > Inventory This is the main culprit (Display Out Of Stock Products = YES) image

I believe there are some settings in the Catalog section that are also affecting the issue:

Catalog - > Catalog image image image image image image image image

Steps to reproduce

  1. Login as admin.
  2. Go to Stores >> configuration >> Catalog >> Inventory >> Display Out Of Stock Products = YES)
  3. On Vanilla 2.4.5 storefront Search for "ryker" it should output two items

/catalogsearch/result/?q=ryker

Expected result

Two items are shown: image

Actual result

But it shows two items and toolbar shows "181 items": image

Additional information

On my site this is creating a problem because each search instead of 2 seconds, becomes a 22 second search. HELP!

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @pmonosolo. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

pmonosolo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @pmonosolo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @pmonosolo, here is your Magento Instance: https://2a84a4e16655dab06981be102116addf.instances.magento-community.engineering Admin access: https://2a84a4e16655dab06981be102116addf.instances.magento-community.engineering/admin_b984 Login: 61d2d9ad Password: 66a216415bd9

pmonosolo commented 1 year ago

Here are tests: https://2a84a4e16655dab06981be102116addf.instances.magento-community.engineering/catalogsearch/result/?q=ryker

BEFORE: image

AFTER: image

pmonosolo commented 1 year ago

@magento give me 2.4.3 instance

magento-deployment-service[bot] commented 1 year ago

Hi @pmonosolo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @pmonosolo, here is your Magento Instance: https://a8564c0d1a87b370b3d016bd8a0ccd93.instances.magento-community.engineering Admin access: https://a8564c0d1a87b370b3d016bd8a0ccd93.instances.magento-community.engineering/admin_417d Login: e183c2fa Password: 360037eda168

pmonosolo commented 1 year ago

Magento 2.4.3 does not have this issue: https://a8564c0d1a87b370b3d016bd8a0ccd93.instances.magento-community.engineering/catalogsearch/result/?q=ryker

BEFORE: image

AFTER: image

pmonosolo commented 1 year ago

It looks like the fix for this issue is in this thread: https://github.com/magento/inventory/issues/3360

I need to test a bit more, but so far, it's outputting only the items in the search.

Bashev commented 1 year ago

Probably fixed in https://github.com/magento/magento2/pull/35986

pmonosolo commented 1 year ago

@Bashev

Probably fixed in #35986

Hmmm, doesnt seem to work. The page loading time is still slow.

The fix in vendor\magento\module-inventory-catalog\Plugin\Catalog\Block\ProductList\UpdateToolbarCount.php

image

It looks like somebody by mistake is calling wrong method - it pulls the WHOLE product collection rather than a collection related to the search.

image

I need to test other parts of the catalog page in case there's some hidden issue thats not related to search.

Although, it should not be really working.

The whole piece of code is being skipped:

image

So this fix migth work for single store with one view, but for others not so much.

Amadeco commented 1 year ago

The both solutions for me doesn't work :

I am on Magento 2.4.5 and PHP 8.1. My guess, if it is working for you, a 3rd party extension (I am using Smile Elasticsuite) but I cannot see any plugins which modify this part of the code. I am not using single-store mode.

pmonosolo commented 1 year ago

The both solutions for me doesn't work :

I am on Magento 2.4.5 and PHP 8.1. My guess, if it is working for you, a 3rd party extension (I am using Smile Elasticsuite) but I cannot see any plugins which modify this part of the code. I am not using single-store mode.

Search for their name in the issues, I believe I've seen somebody working on this issue for that specific plugin.

Amadeco commented 1 year ago

Thank you @pmonosolo for your heads up.

Indeed, I found https://github.com/Smile-SA/elasticsuite/issues/2663#issuecomment-1214813879 but it is the same solution as https://github.com/magento/inventory/issues/3360.

pmonosolo commented 1 year ago

Ah, I just disabled that Plugin.

image

They need to rewrite that to check for:

Currently it just checks the Category page, so on Search Page it uses "Default Category" and outputs the whole catalog.

When you filter by attributes, it does not decrease the number because the only lookup that is done is for Category. It does not check if filters were applied to the category.

m2-assistant[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Lima commented 1 year ago

@magento give me 2.4.5 instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima, here is your Magento Instance: https://615b269acd08405a876118d0c2ac995b.instances.magento-community.engineering Admin access: https://615b269acd08405a876118d0c2ac995b.instances.magento-community.engineering/admin_0a23 Login: 4e78d72a Password: ad018b3eb6ab

engcom-Lima commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima, here is your Magento Instance: https://2a84a4e16655dab06981be102116addf.instances.magento-community.engineering Admin access: https://2a84a4e16655dab06981be102116addf.instances.magento-community.engineering/admin_a285 Login: b693beac Password: cf3997ee3392

engcom-Lima commented 1 year ago

:heavy_check_mark: Issue confirmed

Issue got reproduced in Magento 2.4-develop and 2.4.5

Description: Showing wrong count of items for Ryker product when Display out of stock options is set to Yes.

Pre-requisite: Fresh magento 2.4-develop && 2.4.5 should be installed.

Steps to reproduce:

  1. Login as admin.
  2. Go to Stores >> configuration >> Catalog >> Inventory >> Display Out Of Stock Products = YES)
  3. On Vanilla 2.4.5 storefront Search for "ryker" it should output two items.

Expected result: It should show 2 items for ryker product.

Actual result: It is showing 187 items as shown in screenshot below:

Screenshots:

Screenshot 2022-09-29 at 3 05 05 PM
github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6768 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

pmonosolo commented 1 year ago

Thanks @engcom-Lima !

The issue is not really in the number, its the time it takes to pull the number of the products.

If you have a 300,000 sku store, this is an issue because it outputs the whole catalog 300,000 products on a search page, for EVERY search!

This is why I think there should be two sample data types - one for small store (1000), one for big store (300,000 skus). Some difficult to detect issues are more visible on big stores only.