Skip to content

Commit e447a88

Browse files
Roman HaninRoman Hanin
authored andcommitted
B2B-2243: Optimize addProductsToCart operations
1 parent f75a72d commit e447a88

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

app/code/Magento/Quote/Model/Cart/AddProductsToCart.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ class AddProductsToCart
4646
'The requested qty is not available' => self::ERROR_INSUFFICIENT_STOCK,
4747
];
4848

49-
/**
50-
* @var ProductRepositoryInterface
51-
*/
52-
private $productRepository;
53-
5449
/**
5550
* @var CartRepositoryInterface
5651
*/

app/code/Magento/Quote/Model/Cart/ProductReader.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Quote\Model\Cart;
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1112
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1213
use Magento\Quote\Model\Quote\Config;
1314

@@ -31,6 +32,11 @@ class ProductReader implements ProductReaderInterface
3132
*/
3233
private $quoteConfig;
3334

35+
/**
36+
* @var Collection
37+
*/
38+
private $productCollection;
39+
3440
/**
3541
* @param ProductCollectionFactory $productCollectionFactory
3642
* @param Config $quoteConfig
@@ -44,7 +50,7 @@ public function __construct(
4450
}
4551

4652
/**
47-
* @inheirtdoc
53+
* @inheirtDoc
4854
*/
4955
public function loadProducts(array $skus, int $storeId): void
5056
{
@@ -66,6 +72,6 @@ public function loadProducts(array $skus, int $storeId): void
6672
*/
6773
public function getProductBySku(string $sku) : ?ProductInterface
6874
{
69-
return $this->productsBySku[$sku] ?: null;
75+
return $this->productsBySku[$sku] ?? null;
7076
}
7177
}

app/code/Magento/Quote/Model/Quote.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,6 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C
368368
*/
369369
private $allowedCountriesReader;
370370

371-
/**
372-
* @var Quote\Item[]
373-
*/
374-
private $allItemsCache;
375-
376371
/**
377372
* @param \Magento\Framework\Model\Context $context
378373
* @param \Magento\Framework\Registry $registry

0 commit comments

Comments
 (0)