Magento – Magento 2.2.4 place order exception error “Undefined index: product_id Issue”

magento2place-order

I have upgraded Magento with Latest version 2.2.4 and trying to place order.It produce below exception error

[2018-06-26 12:40:50] main.CRITICAL: Notice: Undefined index: product_id in /var/www/html/magento2/vendor/magento/module-catalog-inventory/Model/StockManagement.php on line 103 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: product_id in /var/www/html/magento2/vendor/magento/module-catalog-inventory/Model/StockManagement.php on line 103 at /var/www/html/magento2/vendor/magento/framework/App/ErrorHandler.php:61)"} []

I have checked in file and found that array variable is producing error

$productId = $lockedItemRecord['product_id'];

I have tried and changed this with Hard coded then it is working fine.I am not getting what is the issue in this code.

$productId = "395";

I have already compiled all code and tested in both mode developer and production.

Please support me to resolve this issue.

Best Answer

I had the same problem.

After searching the source of Magento 2.2.4 I found the function in file (vendor\magento\module-catalog-inventory\Model\Configuration.php):

public function getDefaultScopeId()
{
    // TODO: should be fixed in MAGETWO-46043
    // "0" is id of admin website, which is used in backed during save entity
    return 0;
}

In my case I modify Store parameters at "Stores > All Stores" and my actual store_id/scope_id was 1 and not 0. After changing "return 0" to "return 1", my problem was solved.

As this is anyhow TODO for Magento I expect, that in next upgrade this will be solved and all my modification will be overwritten and everything should work at that time...

Related Topic