Skip to content

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

Open
@zakdma

Description

@zakdma

Preconditions and environment

  • Magento version is the latest 2.4.7-p2
  • Varnish is used as FPC
  • Indexers are in UPDATE BY SCHEDULE mode
  • Cron is running

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
  1. 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: cat_p_) 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

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: ProductComponent: StockIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: dev in progressReported on 2.4.7-p2Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions