inventory
inventory copied to clipboard
\Magento\InventoryShipping\Model\InventoryRequestFromOrderFactory not working for bundle products
Preconditions (*)
- Magento 2.4.3-p1
- Inventory 1.2.1-p1
Steps to reproduce (*)
- Create a bundle product with one physical item and 2 virtual ones
- Place an order with the bundle product
- Make sure the order doesn't have any other type of product
- Create a sample class
<?php
/**
namespace Vendor\Module\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\InventoryShipping\Model\InventoryRequestFromOrderFactory;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\OrderItemInterface;
class SourceSelection extends AbstractHelper
{
protected $inventoryRequestFromOrderFactory;
protected $sourceSelectionService;
public function __construct(
\Magento\InventorySourceSelectionApi\Api\SourceSelectionServiceInterface $sourceSelectionService,
InventoryRequestFromOrderFactory $inventoryRequestFromOrderFactory,
Context $context
)
{
$this->inventoryRequestFromOrderFactory = $inventoryRequestFromOrderFactory;
$this->sourceSelectionService = $sourceSelectionService;
parent::__construct($context);
}
public function getAlgorithmSourceCode()
{
return $this->scopeConfig->getValue('vendor/orders/source_selection_algorithm_code');
}
/**
* @param OrderInterface $order
* @return void
*/
public function getPreferredSource($order)
{
$inventoryRequest = $this->inventoryRequestFromOrderFactory->create($order);
$result = $this->sourceSelectionService->execute($inventoryRequest, $this->getAlgorithmSourceCode());
return $result;
}
}
However the same issue doesn't happen when you ship the order from the backend and everything works as expected.
Expected result (*)
The $inventoryRequest
contains the bundle SKU product
This is the sample inventory request created when shipping the product via the backend. As you can see it contains one product the physical one.
Actual result (*)
- The
$inventoryRequest
contains an empty items array
Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
- Join Magento Community Engineering Slack and ask your questions in #github channel.
We were able to reproduce this as well.