Skip to content

Commit a2a8cf2

Browse files
committed
MC-42443: Row Sub Total is not updated with new price when Price is updated through API
- Fixed the PR comments. - Added the Integration test.
1 parent c43d9b6 commit a2a8cf2

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

app/code/Magento/Quote/Model/Product/Plugin/UpdateQuote.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function __construct(
4646
}
4747

4848
/**
49+
* Update the quote trigger_recollect column is 1 when product price is changed through API.
50+
*
4951
* @param TierPriceStorageInterface $subject
5052
* @param $result
5153
* @param $prices
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Model\Product\Plugin;
9+
10+
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
13+
use PHPUnit\Framework\TestCase;
14+
15+
/**
16+
* Tests for update quote plugin.
17+
*
18+
* @magentoAppArea adminhtml
19+
*/
20+
class UpdateQuoteTest extends TestCase
21+
{
22+
/**
23+
* @var GetQuoteByReservedOrderId
24+
*/
25+
private $getQuoteByReservedOrderId;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
protected function setUp(): void
31+
{
32+
parent::setUp();
33+
34+
$objectManager = Bootstrap::getObjectManager();
35+
$this->getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class);
36+
}
37+
38+
/**
39+
* Test to update the column trigger_recollect is 1 from quote table.
40+
*
41+
* @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
42+
* @return void
43+
*/
44+
public function testUpdateQuoteRecollectAfterChangeProductPrice(): void
45+
{
46+
$quote = $this->getQuoteByReservedOrderId->execute('test_order_with_simple_product_without_address');
47+
$this->assertNotNull($quote);
48+
$this->assertFalse((bool)$quote->getTriggerRecollect());
49+
$this->assertNotEmpty($quote->getItems());
50+
$quoteItem = current($quote->getItems());
51+
$product = $quoteItem->getProduct();
52+
53+
/** @var QuoteResource $quoteResource */
54+
$quoteResource = $quote->getResource();
55+
$quoteResource->markQuotesRecollect($product->getId());
56+
/** @var AdapterInterface $connection */
57+
$connection = $quoteResource->getConnection();
58+
$select = $connection->select()
59+
->from(
60+
$quoteResource->getTable('quote'),
61+
['trigger_recollect']
62+
)->where(
63+
"reserved_order_id = 'test_order_with_simple_product_without_address'"
64+
);
65+
66+
$quoteRow = $connection->fetchRow($select);
67+
$this->assertNotEmpty($quoteRow);
68+
$this->assertTrue((bool)$quoteRow['trigger_recollect']);
69+
}
70+
}

0 commit comments

Comments
 (0)