magento / magento/inventory

\Magento\InventoryShipping\Model\InventoryRequestFromOrderFactory not working for bundle products

Open
#3,369 2 comments 2 reactions 0 assignees View on GitHub
Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### Preconditions (*)

1. Magento 2.4.3-p1
2. Inventory 1.2.1-p1

### Steps to reproduce (*)

1. Create a bundle product with one physical item and 2 virtual ones

![image](https://user-images.githubusercontent.com/20220341/210531675-8ba1d24d-b396-4f67-86fa-1fc52bf33a2a.png)

3. Place an order with the bundle product
4. Make sure the order doesn't have any other type of product
5. Create a sample class

```
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.

![image](https://user-images.githubusercontent.com/20220341/210530246-d52667e4-2073-48b9-8e6b-9eebec93ea1f.png)
![image](https://user-images.githubusercontent.com/20220341/210529568-955e8d39-b6e8-401b-ae61-b9fbef91db09.png)

### Actual result (*)
1. The `$inventoryRequest` contains an empty items array

![image](https://user-images.githubusercontent.com/20220341/210529704-abe2f83c-6cdd-4559-ae94-dc1892a9cb8c.png)

Contributor guide

Open the contributing guide

Research direction

Start by reading Magento\InventoryShipping\Model\InventoryRequestFromOrderFactory and tracing the create($order) call shown in the SourceSelection sample. Reproduce the bundle-order case on Magento 2.4.3-p1 with Inventory 1.2.1-p1, compare the resulting request with backend shipping, and confirm that the request includes the physical bundle item rather than an empty items array.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.