Skip to content

Commit fe4aab0

Browse files
authored
Merge pull request magento#2918 from sidolov/revert-MSI-2719
Revert MSI-2719
2 parents fb505fb + 6892273 commit fe4aab0

12 files changed

+11
-621
lines changed

InventorySales/Model/AreProductsSalableForRequestedQty.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

InventorySales/Model/AreProductsSalableForRequestedQty/ProductsSalableInfo.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

InventorySales/Model/CheckItemsQuantity.php

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,43 @@
77

88
namespace Magento\InventorySales\Model;
99

10-
use Magento\Framework\App\ObjectManager;
1110
use Magento\Framework\Exception\LocalizedException;
12-
use Magento\InventorySalesApi\Api\AreProductsSalableForRequestedQtyInterface;
13-
use Magento\InventorySalesApi\Api\Data\ProductSalabilityErrorInterface;
14-
use Magento\InventorySalesApi\Api\Data\ProductSalableForRequestedQtyInfoInterfaceFactory;
1511
use Magento\InventorySalesApi\Api\IsProductSalableForRequestedQtyInterface;
12+
use Magento\InventorySalesApi\Api\Data\ProductSalableResultInterface;
13+
use Magento\InventorySalesApi\Api\Data\ProductSalabilityErrorInterface;
1614

1715
/**
1816
* Verify items are salable for requested quantity.
1917
*/
2018
class CheckItemsQuantity
2119
{
2220
/**
23-
* @var AreProductsSalableForRequestedQtyInterface
24-
*/
25-
private $areProductsSalableForRequestedQty;
26-
27-
/**
28-
* @var ProductSalableForRequestedQtyInfoInterfaceFactory
21+
* @var IsProductSalableForRequestedQtyInterface
2922
*/
30-
private $salableForRequestedQtyInfoFactory;
23+
private $isProductSalableForRequestedQty;
3124

3225
/**
33-
* @param IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty @deprecated
34-
* @param ProductSalableForRequestedQtyInfoInterfaceFactory|null $salableForRequestedQtyInfoFactory
35-
* @param AreProductsSalableForRequestedQtyInterface $areProductsSalableForRequestedQty
36-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
26+
* @param IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty
3727
*/
3828
public function __construct(
39-
IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty,
40-
ProductSalableForRequestedQtyInfoInterfaceFactory $salableForRequestedQtyInfoFactory = null,
41-
AreProductsSalableForRequestedQtyInterface $areProductsSalableForRequestedQty = null
29+
IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty
4230
) {
43-
$this->areProductsSalableForRequestedQty = $areProductsSalableForRequestedQty ?: ObjectManager::getInstance()
44-
->get(AreProductsSalableForRequestedQtyInterface::class);
45-
$this->salableForRequestedQtyInfoFactory = $salableForRequestedQtyInfoFactory ?: ObjectManager::getInstance()
46-
->get(ProductSalableForRequestedQtyInfoInterfaceFactory::class);
31+
$this->isProductSalableForRequestedQty = $isProductSalableForRequestedQty;
4732
}
4833

4934
/**
5035
* Check whether all items salable
5136
*
52-
* @param array $items ['sku' => 'qty', ...]
37+
* @param array $items [['sku' => 'qty'], ...]
5338
* @param int $stockId
5439
* @return void
5540
* @throws LocalizedException
5641
*/
5742
public function execute(array $items, int $stockId): void
5843
{
59-
$skuRequests = [];
6044
foreach ($items as $sku => $qty) {
61-
$skuRequests[] = $this->salableForRequestedQtyInfoFactory->create(['sku' => $sku, 'qty' => $qty]);
62-
}
63-
$result = $this->areProductsSalableForRequestedQty->execute($skuRequests, $stockId);
64-
foreach ($result->getSalable() as $isSalable) {
45+
/** @var ProductSalableResultInterface $isSalable */
46+
$isSalable = $this->isProductSalableForRequestedQty->execute((string)$sku, $stockId, (float)$qty);
6547
if (false === $isSalable->isSalable()) {
6648
$errors = $isSalable->getErrors();
6749
/** @var ProductSalabilityErrorInterface $errorMessage */

InventorySales/Model/ProductSalableResult.php

Lines changed: 0 additions & 96 deletions
This file was deleted.

InventorySales/Model/ProductsSalableResult.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)