Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ioweb-gr opened this issue Jan 4, 2023 · 2 comments

Comments

@ioweb-gr
Copy link

ioweb-gr commented Jan 4, 2023

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

  1. Place an order with the bundle product
  2. Make sure the order doesn't have any other type of product
  3. 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.

image
image

Actual result (*)

  1. The $inventoryRequest contains an empty items array

image

@m2-assistant
Copy link

m2-assistant bot commented Jan 4, 2023

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


@Megaventory
Copy link

We were able to reproduce this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants