Skip to content

Commit a815c38

Browse files
committed
MC-42443: Row Sub Total is not updated with new price when Price is updated through API
- Fixed the CR comments.
1 parent f61bb08 commit a815c38

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/Product/Plugin/UpdateQuoteTest.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
use Magento\TestFramework\Helper\Bootstrap;
1111
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
12+
use Magento\Catalog\Api\ProductRepositoryInterface;
13+
use Magento\Quote\Api\Data\CartItemInterfaceFactory;
1214
use Magento\Catalog\Api\TierPriceStorageInterface;
1315
use Magento\Catalog\Api\Data\TierPriceInterfaceFactory;
16+
1417
use PHPUnit\Framework\TestCase;
1518

1619
/**
@@ -23,6 +26,12 @@ class UpdateQuoteTest extends TestCase
2326
*/
2427
private $getQuoteByReservedOrderId;
2528

29+
/** @var ProductRepositoryInterface */
30+
private $productRepository;
31+
32+
/** @var CartItemInterfaceFactory */
33+
private $itemFactory;
34+
2635
/**
2736
* @var TierPriceStorageInterface
2837
*/
@@ -44,37 +53,49 @@ protected function setUp(): void
4453
$this->getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class);
4554
$this->tierPriceStorage = $objectManager->get(TierPriceStorageInterface::class);
4655
$this->tierPriceFactory = $objectManager->get(TierPriceInterfaceFactory::class);
56+
$this->itemFactory = $objectManager->get(CartItemInterfaceFactory::class);
57+
$this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
4758
}
4859

4960
/**
5061
* Test to update the column trigger_recollect is 1 from quote table.
5162
*
52-
* @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
53-
* @magentoDbIsolation disabled
63+
* @magentoDataFixture Magento/Sales/_files/quote.php
64+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
5465
* @return void
5566
*/
5667
public function testUpdateQuoteRecollectAfterChangeProductPrice(): void
5768
{
58-
$quoteId = 'test_order_with_simple_product_without_address';
69+
$quoteId = 'test01';
70+
$productSku = 'simple';
5971
$quote = $this->getQuoteByReservedOrderId->execute($quoteId);
60-
$this->assertNotNull($quote);
61-
$this->assertFalse((bool)$quote->getTriggerRecollect());
62-
$this->assertNotEmpty($quote->getItems());
63-
$quoteItem = current($quote->getItems());
64-
$product = $quoteItem->getProduct();
72+
73+
$quoteItem = $this->itemFactory->create();
74+
75+
$product = $this->productRepository->get($productSku);
76+
77+
$quoteItem->setProduct($product);
6578
$quoteItem->setProductId($product->getRowId());
79+
80+
$quote->addItem($quoteItem);
81+
$quote->setTriggerRecollect(0);
6682
$quote->save();
6783

84+
$this->assertNotNull($quote);
85+
$this->assertFalse((bool)$quote->getTriggerRecollect());
86+
6887
$tierPrice = $this->tierPriceFactory->create();
6988
$tierPrice->setPrice($product->getPrice());
7089
$tierPrice->setPriceType('fixed');
7190
$tierPrice->setWebsiteId(0);
7291
$tierPrice->setSku($product->getSku());
7392
$tierPrice->setCustomerGroup('ALL GROUPS');
7493
$tierPrice->setQuantity(1);
94+
7595
$this->tierPriceStorage->update([$tierPrice]);
7696

7797
$quote = $this->getQuoteByReservedOrderId->execute($quoteId);
98+
7899
$this->assertNotEmpty($quote->getTriggerRecollect());
79100
$this->assertTrue((bool)$quote->getTriggerRecollect());
80101
}

0 commit comments

Comments
 (0)