2

I am getting this error when running bin/magento inventory:reservation:list-inconsistencies:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Magento\Inventory\Model\ResourceModel\IsProductAssignedToStock::execute() must be of the type string, integer given, called in /mydomain/http/vendor/magento/module-inventory-reservation-cli/Model/SalableQuantityInconsistency/FilterManagedStockProducts.php on line 56 and defined in /mydomain/http/vendor/magento/module-inventory/Model/ResourceModel/IsProductAssignedToStock.php:34
Stack trace:
#0 /mydomain/http/vendor/magento/module-inventory-reservation-cli/Model/SalableQuantityInconsistency/FilterManagedStockProducts.php(56): Magento\Inventory\Model\ResourceModel\IsProductAssignedToStock->execute(1091634, 1)
#1 /mydomain/http/vendor/magento/module-inventory-reservation-cli/Model/GetSalableQuantityInconsistencies.php(105): Magento\InventoryReservationCli\Model\SalableQua in /mydomain/http/vendor/magento/module-inventory/Model/ResourceModel/IsProductAssignedToStock.php on line 34

Any ideas on how to solve this?

2

Here is the temporary fix. If you really wanna get rid of this error then update below function by type casting to string.

/vendor/magento/module-inventory-reservation-cli/Model/SalableQuantityInconsistency/FilterManagedStockProducts.php

Line 56 and 60

    /**
     * Remove all reservations with incomplete state
     *
     * @param SalableQuantityInconsistency[] $inconsistencies
     * @return SalableQuantityInconsistency[]
     * @throws LocalizedException
     * @throws SkuIsNotAssignedToStockException
     */
public function execute(array $inconsistencies): array
    {
        foreach ($inconsistencies as $inconsistency) {
            $filteredItems = [];
            foreach ($inconsistency->getItems() as $sku => $qty) {
                if (false === $this->isProductAssignedToStock->execute((string)$sku, $inconsistency->getStockId())) {
                    continue;
                }

                $stockConfiguration = $this->getStockItemConfiguration->execute((string)$sku, $inconsistency->getStockId());
                if ($stockConfiguration->isManageStock()) {
                    $filteredItems[$sku] = $qty;
                }
            }
            $inconsistency->setItems($filteredItems);
        }

        return $inconsistencies;
    }

Now run the command.

bin/magento inventory:reservation:list-inconsistencies

Courtesy : https://github.com/magento/inventory/issues/2522

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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