2

The problem I'm facing is that The table Inventory_stock_13 used for the 2nd website is updated incorrectly. When set source status to Out of stock, column is_salable is still 1 and quantity is updated to 0 instead.
Expected result must be is_salable to 0 and quantity unchanged.

I can only see the default stock item get saved but cannot find where the code update table 'Inventory_stock_13'?
Hope you guys have a hint for me. Thank you.

I'm working on magento 2.4.3 by the way.

1 Answer 1

1

I figured it out myself. Patch these two will get the other inventory stocks updated like the logic of the default one.

@package magento/module-inventory-indexer
--- Indexer/SelectBuilder.php

+++ Indexer/SelectBuilder.php   (date 1631043163343)
@@ -79,11 +79,12 @@
             []
         );

+        $this->getIsStockItemSalableCondition->stockStatusColumn = '`status`';
         $select->from(
             ['source_item' => $sourceItemTable],
             [
                 SourceItemInterface::SKU,
-                IndexStructure::QUANTITY => 'SUM(' . $quantityExpression . ')',
+                IndexStructure::QUANTITY => 'SUM(`' . SourceItemInterface::QUANTITY . '`)',
                 IndexStructure::IS_SALABLE => $this->getIsStockItemSalableCondition->execute($select),
             ]
         )


@package magento/module-inventory-sales
--- Model/ResourceModel/IsStockItemSalableCondition/IsStockItemSalableConditionChain.php
+++ Model/ResourceModel/IsStockItemSalableCondition/IsStockItemSalableConditionChain.php    (date 1631043236344)
@@ -66,6 +66,6 @@
         }

         $isSalableString = '(' . implode(') OR (', $conditionStrings) . ')';
-        return (string)$this->resourceConnection->getConnection()->getCheckSql($isSalableString, 1, 0);
+        return (string)$this->resourceConnection->getConnection()->getCheckSql($isSalableString, isset($this->stockStatusColumn) ? $this->stockStatusColumn : 1, 0);
     }
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.