0

I have configured a Bundle products comprised of Virtul & Simple products and using fixed pricing for each bundle option.

When trying to create order at checkout and creating invoice behind the scene, it is throwing error

PHP Fatal error: Uncaught TypeError: Return value of Magento\InventorySourceSelection\Model\Request\InventoryRequest::getItems() must be of the type array, null returned in /www/vendor/magento/module-inventory-source-selection/Model/Request/InventoryRequest.php:102

I was looking for the solution and found out that this is a bug in Magento 2.3 reported at https://github.com/magento/inventory/issues/3172

The above reported issue is still not resolved by Magento. Is there anyone else who faced such issue? Looking for some suggestions here about how to handle this issue using Magento 2.3

P.S I am trying to create invoice immediately after the transaction is authorized i.e. when customer palces order from checkout via Stripe

1 Answer 1

0

So, I resolved this issue by overriding the class

Magento\InventorySourceSelection\Model\Request\InventoryRequest.php

and then redefined below method

/**
 * @inheritdoc
 */
public function getItems(): array
{
    /**
        Return array() if value is NULL 
    */
    if(empty($this->items))
    {
        return array();
    }

    return $this->items;
}

So now getItems() will return array() if the value of $items is NULL. And will resolve this problem.

Further, it seems like this issue was to be fixed by Magento team in 2.3 as you can see a note in Magento\InventorySourceSelection\Model\Request\InventoryRequest at Line: 76 where the $items is defined. It says:

//TODO: Temporary fix for resolving issue with webApi (https://github.com/magento-engcom/msi/issues/1524)

Your Answer

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

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