magento2: SQL error on 2.4.4 prerelease when saving a product with new source and stock
Preconditions (*)
- Magento 2.4.4 prerelease
- PHP 8.1
- Magento with prefix in DB
Steps to reproduce (*) 1.Create new source 2.Create new stock and assign for new source 4. Going to: Catalog–>Product–> Open random product, Assigning for new Source, add Q-ty 5. Push the Save button
Expected result (*)
- Success after save wtihout error, and seeing on the Products Greed Q-ty >0 in column Stock
Actual result (*)
- SQL Error and on the Products Grid in column Stock=0 and not displaying on FrontArea:
https://imgur.com/a/Mj7vS0x https://imgur.com/a/POWJtKH
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘docker_mg244eegolaya.pref_reservations_temp_for_stock_2’ doesn’t exist, query was: SELECT
source_item.sku, SUM(IF(source_item.status = 0, 0, source_item.quantity)) ASquantity, IF((reservations.reservation_qty IS NULL OR (SUM(source_item.quantity) + reservations.reservation_qty) > 0) AND (((legacy_stock_item.use_config_backorders = 0 AND legacy_stock_item.backorders <> 0) AND (legacy_stock_item.min_qty >= 0 OR legacy_stock_item.qty > legacy_stock_item.min_qty) AND SUM(IF(source_item.status = 0, 0, 1))) OR ((legacy_stock_item.use_config_manage_stock = 0 AND legacy_stock_item.manage_stock = 0)) OR ((legacy_stock_item.use_config_min_qty = 1 AND SUM(IF(source_item.status = 0, 0, source_item.quantity)) > 0) OR (legacy_stock_item.use_config_min_qty = 0 AND SUM(IF(source_item.status = 0, 0, source_item.quantity)) > legacy_stock_item.min_qty)) OR (product.sku IS NULL)), 1, 0) ASis_salableFROMpref_inventory_source_itemASsource_itemLEFT JOINpref_catalog_product_entityASproductON product.sku = source_item.sku AND (product.created_in <= 1 AND product.updated_in > 1) LEFT JOINpref_cataloginventory_stock_itemASlegacy_stock_itemON product.entity_id = legacy_stock_item.product_id LEFT JOINpref_reservations_temp_for_stock_2ASreservationsON source_item.sku = reservations.sku WHERE (source_item.source_code IN (‘a2’)) AND (source_item.sku IN (‘24-MB01’)) GROUP BYsource_item.sku
Severity (*) S0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- MC-41862: Stock status resets to saleable when the product is saved from Admin — committed to magento/inventory by sidolov 3 years ago
The commit @engcom-Alfa mentioned doesn’t seem to be correct, this one seems a lot more related: https://github.com/magento/inventory/commit/d236405c22d3005c642c70348cfd372dbcb98b76