Skip to content

Commit

Permalink
Merge pull request #17 from kernstmediarox/master
Browse files Browse the repository at this point in the history
[Bugfix] changed product validation for deduction
  • Loading branch information
convenient authored Sep 3, 2020
2 parents abd3b32 + 3c454aa commit 1bb78a3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Model/GetSourceSelectionResultFromOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ampersand\DisableStockReservation\Model\GetInventoryRequestFromOrder;
use Magento\Framework\App\ObjectManager;
use Magento\InventoryConfigurationApi\Model\IsSourceItemManagementAllowedForProductTypeInterface;
use Magento\InventorySalesApi\Model\GetSkuFromOrderItemInterface;
use Magento\InventorySourceSelectionApi\Api\Data\ItemRequestInterfaceFactory;
use Magento\Sales\Api\Data\OrderInterface;
Expand Down Expand Up @@ -41,6 +42,13 @@ class GetSourceSelectionResultFromOrder
private $getInventoryRequestFromOrder;

/**
* @var IsSourceItemManagementAllowedForProductTypeInterface
*/
private $isSourceItemManagementAllowedForProductType;


/**
* @param IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType
* @param GetSkuFromOrderItemInterface $getSkuFromOrderItem
* @param ItemRequestInterfaceFactory $itemRequestFactory
* @param GetDefaultSourceSelectionAlgorithmCodeInterface $getDefaultSourceSelectionAlgorithmCode
Expand All @@ -49,12 +57,14 @@ class GetSourceSelectionResultFromOrder
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType,
GetSkuFromOrderItemInterface $getSkuFromOrderItem,
ItemRequestInterfaceFactory $itemRequestFactory,
GetDefaultSourceSelectionAlgorithmCodeInterface $getDefaultSourceSelectionAlgorithmCode,
SourceSelectionServiceInterface $sourceSelectionService,
GetInventoryRequestFromOrder $getInventoryRequestFromOrder = null
) {
$this->isSourceItemManagementAllowedForProductType = $isSourceItemManagementAllowedForProductType;
$this->itemRequestFactory = $itemRequestFactory;
$this->getDefaultSourceSelectionAlgorithmCode = $getDefaultSourceSelectionAlgorithmCode;
$this->sourceSelectionService = $sourceSelectionService;
Expand Down Expand Up @@ -90,7 +100,7 @@ private function getSelectionRequestItems($orderItems): array
$selectionRequestItems = [];
/** @var \Magento\Sales\Model\Order\Item $orderItem */
foreach ($orderItems as $orderItem) {
if ($orderItem->isDummy()) {
if (!$this->isSourceItemManagementAllowedForProductType->execute($orderItem->getProductType())) {
continue;
}

Expand Down

0 comments on commit 1bb78a3

Please sign in to comment.