magento2: catalog_product_price is not populated with products when back in stock

Preconditions and environment

  • 2.4.6-p1
  • With sample data

Steps to reproduce

  1. Create a Magento 2.4.6-p1 instance
  2. Install sample data
  3. Check core_config_data cataloginventory/options/show_out_of_stock is set to 0 (default value)
  4. Take a product without related/crosssell/upsell products (no catalog_product_link). !!! IMPORTANT !!! because this products will trigger an insert in catalog_product_price_cl
  5. Set indexer as scheduled bin/magento indexer:set-mode schedule
  6. Set product from Adminhtml as out_of_stock with a stock of 0 and save => the product is not removed from catalog_product_index_price and catalog_product_price_cl is not populated
  7. Run n98-magerun2 sys:cron:run indexer_update_all_views => catalog_product_index_price are not removed for this product
  8. Remove lines from catalog_product_index_price for this product
  9. Set product with in_stock and a stock of 8 then save it => catalog_product_price_cl is not populated so partial reindex will not fill catalog_product_index_price table
  10. Run n98-magerun2 sys:cron:run indexer_update_all_views => catalog_product_index_price is not filled by this product

Expected result

We expect to fill/remove from catalog_product_index_price when a product switch from out_of_stock and in_stock. The main issue is that there is not trigger to insert the concerning product in catalog_product_price_cl when the cataloginventory_stock_item change

Actual result

Product data are missing/disappear from catalog_product_index_price

Additional information

The issue comes from this commit :

https://github.com/magento/magento2/commit/b3969936251e1a03427cd24c209abb6af3a0ce1b

Triggers are not well created on cataloginventory_stock_item to fill the table catalog_product_price_cl when stock change.

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”.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 17 (4 by maintainers)

Most upvoted comments

Hi @sebfie,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.The issue is reproducible with partial reindexing,

  • scheduled reindex is enabled
  • Switch product when in_stock to out_of_stock
  • Run partial reindex => n98-magerun2 sys:cron:run indexer_update_all_views
  • Product does not disappear from catalog_product_index_price
  • Switch product out_of_stock to in_stock
  • Run partial reindex => n98-magerun2 sys:cron:run indexer_update_all_views
  • Product does not reappear to catalog_product_index_price
Screenshot 2023-09-11 at 6 52 42 PM Screenshot 2023-09-11 at 6 54 29 PM Screenshot 2023-09-11 at 7 44 28 PM

Here product id is 2 not disappearing after doing Partial Reindexing.

Hence Confirming the issue.

Thanks.

Thx a lot. I refered the commit I think responsible of that. Take a look :

https://github.com/magento/magento2/commit/b3969936251e1a03427cd24c209abb6af3a0ce1b