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.46k stars 9.28k forks source link

Product stock status change does not purge product varnish cache #39056

Open zakdma opened 4 weeks ago

zakdma commented 4 weeks ago

Preconditions and environment

Steps to reproduce

  1. Logon into admin panel
  2. Go to Stores>Configuration>Catalog>Inventory. Open the Stock Options dropdown. Set Yes in the Display Out of Stock Products option
  3. Create a simple product with a stock quantity (id = 1, SKU = simple1)
  4. Please note: Varnish cache should be enabled
  5. Go to System > Extensions > Integrations
  6. Add new integration.
  7. Below the General section enter Name, Email (optional), and Password.
  8. In the left menu, click API.
  9. From the Resource Access drop-down menu, select All.
  10. Click Save
  11. On the Integrations page, next to the newly created integration, click Activate.
  12. On the Integration page, you can find the list of the resources, click Allow.
  13. The Integration Token Details are generated.
  14. Copy and save Access Token to use it further
  15. Click Done.
  16. Go to Stores > Configuration > Services > OAuth > Consumer Settings > Allow OAuth Access Tokens to be used as standalone Bearer tokens option to Yes. Save configuration.
  17. Open the product on the front and see it's in stock
  18. Use any REST client and run the request
    curl -X PUT "https://<magento-host>/rest/V1/products/simple1/stockItems/1" -H "Authorization: Bearer <access-token>" -H "Content-Type:application/json" --globoff -k --data-binary @- << EOF
    {
    "stock_item": {
    "qty": 55.0,
    "is_in_stock": false
    }
    }
    EOF
  19. Refresh the front product page.

Expected result

Product became "Out of Stock" on the front page

Actual result

Product is still "In Stock" on the front page

Additional information

The problem is that Stock indexer does not reset FPC for product (tag: catp) when reindexed See stock indexer implementation https://github.com/magento/magento2/blame/2.4-develop/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php#L84 and compare it with the Price indexer https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Model/Indexer/Product/Price.php#L96

Release note

No response

Triage and priority

m2-assistant[bot] commented 4 weeks ago

Hi @zakdma. Thank you for your report. To speed up processing of this issue, 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:

andrewbess commented 4 weeks ago

Hello @zakdma Thank you for your contribution Great catch Could you please provide the fix Thank you in advance.

m2-assistant[bot] commented 2 weeks ago

Hi @engcom-Delta. 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-Delta commented 2 weeks ago

Hi @zakdma ,

Thanks for your reporting and collaboration. We have verified the issue in latest 2.4-develop instance and the issue is reproducible. Kindly refer the screenshots.

Steps to Reproduce 1.Go to Stores>Configuration>Catalog>Inventory. Open the Stock Options dropdown. Set Yes in the Display Out of Stock Products option image

  1. Enable Varnish Cache image
  2. Create a simple product with a stock quantity (id = 1, SKU = simple1) image
  3. Go to System > Extensions > Integrations
  4. Add new integration.
  5. Below the General section enter Name, Email (optional), and Password.
  6. In the left menu, click API.
  7. From the Resource Access drop-down menu, select All.
  8. Click Save
  9. On the Integrations page, next to the newly created integration, click Activate.
  10. On the Integration page, you can find the list of the resources, click Allow.
  11. The Integration Token Details are generated.
  12. Copy and save Access Token to use it further
  13. Click Done. 15.Go to Stores > Configuration > Services > OAuth > Consumer Settings > Allow OAuth Access Tokens to be used as standalone Bearer tokens option to Yes. Save configuration. 16.Open the product on the front and see it's in stock image
  14. Use any REST client and run the request image
  15. Refresh the front product page. Observe product is still in stock. image

Thanks.

github-jira-sync-bot commented 2 weeks ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 1 week ago

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

m2-assistant[bot] commented 1 week ago

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