Skip to content

Commit

Permalink
ENGCOM-3271: fixed Quote Item Prices are NULL in cart related events. #…
Browse files Browse the repository at this point in the history
…18685 #18808

 - Merge Pull Request #18808 from ashutoshwebkul/magento2:2.2-develop
 - Merged commits:
   1. 09586e4
   2. 1638891
   3. 175ebc0
   4. 59bd874
  • Loading branch information
magento-engcom-team committed Oct 31, 2018
2 parents 1cf0258 + 59bd874 commit f009a5f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Quote/Model/Quote/Item/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function prepare(Item $item, DataObject $request, Product $candidate)
$item->addQty($candidate->getCartQty());

$customPrice = $request->getCustomPrice();
$item->setPrice($candidate->getFinalPrice());
if (!empty($customPrice)) {
$item->setCustomPrice($customPrice);
$item->setOriginalCustomPrice($customPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ protected function setUp()
'addQty',
'setCustomPrice',
'setOriginalCustomPrice',
'setData'
'setData',
'setprice'
]);
$this->quoteItemFactoryMock->expects($this->any())
->method('create')
Expand All @@ -98,7 +99,13 @@ protected function setUp()

$this->productMock = $this->createPartialMock(
\Magento\Catalog\Model\Product::class,
['getCustomOptions', '__wakeup', 'getParentProductId', 'getCartQty', 'getStickWithinParent']
[
'getCustomOptions',
'__wakeup',
'getParentProductId',
'getCartQty',
'getStickWithinParent',
'getFinalPrice']
);
$this->objectMock = $this->createPartialMock(
\Magento\Framework\DataObject::class,
Expand Down Expand Up @@ -239,13 +246,17 @@ public function testPrepare()
$customPrice = 400000000;
$itemId = 1;
$requestItemId = 1;
$finalPrice = 1000000000;

$this->productMock->expects($this->any())
->method('getCartQty')
->will($this->returnValue($qty));
$this->productMock->expects($this->any())
->method('getStickWithinParent')
->will($this->returnValue(false));
$this->productMock->expects($this->once())
->method('getFinalPrice')
->will($this->returnValue($finalPrice));

$this->itemMock->expects($this->once())
->method('addQty')
Expand All @@ -255,6 +266,9 @@ public function testPrepare()
->will($this->returnValue($itemId));
$this->itemMock->expects($this->never())
->method('setData');
$this->itemMock->expects($this->once())
->method('setPrice')
->will($this->returnValue($this->itemMock));

$this->objectMock->expects($this->any())
->method('getCustomPrice')
Expand Down Expand Up @@ -282,13 +296,17 @@ public function testPrepareWithResetCountAndStick()
$customPrice = 400000000;
$itemId = 1;
$requestItemId = 1;
$finalPrice = 1000000000;

$this->productMock->expects($this->any())
->method('getCartQty')
->will($this->returnValue($qty));
$this->productMock->expects($this->any())
->method('getStickWithinParent')
->will($this->returnValue(true));
$this->productMock->expects($this->once())
->method('getFinalPrice')
->will($this->returnValue($finalPrice));

$this->itemMock->expects($this->once())
->method('addQty')
Expand All @@ -298,6 +316,9 @@ public function testPrepareWithResetCountAndStick()
->will($this->returnValue($itemId));
$this->itemMock->expects($this->never())
->method('setData');
$this->itemMock->expects($this->once())
->method('setPrice')
->will($this->returnValue($this->itemMock));

$this->objectMock->expects($this->any())
->method('getCustomPrice')
Expand Down Expand Up @@ -325,13 +346,17 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
$customPrice = 400000000;
$itemId = 1;
$requestItemId = 2;
$finalPrice = 1000000000;

$this->productMock->expects($this->any())
->method('getCartQty')
->will($this->returnValue($qty));
$this->productMock->expects($this->any())
->method('getStickWithinParent')
->will($this->returnValue(false));
$this->productMock->expects($this->once())
->method('getFinalPrice')
->will($this->returnValue($finalPrice));

$this->itemMock->expects($this->once())
->method('addQty')
Expand All @@ -341,6 +366,9 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
->will($this->returnValue($itemId));
$this->itemMock->expects($this->never())
->method('setData');
$this->itemMock->expects($this->once())
->method('setPrice')
->will($this->returnValue($this->itemMock));

$this->objectMock->expects($this->any())
->method('getCustomPrice')
Expand Down Expand Up @@ -368,6 +396,7 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
$customPrice = 400000000;
$itemId = 1;
$requestItemId = 1;
$finalPrice = 1000000000;

$this->objectMock->expects($this->any())
->method('getResetCount')
Expand All @@ -386,10 +415,16 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
$this->productMock->expects($this->any())
->method('getStickWithinParent')
->will($this->returnValue(false));
$this->productMock->expects($this->once())
->method('getFinalPrice')
->will($this->returnValue($finalPrice));

$this->itemMock->expects($this->once())
->method('addQty')
->with($qty);
$this->itemMock->expects($this->once())
->method('setPrice')
->will($this->returnValue($this->itemMock));

$this->objectMock->expects($this->any())
->method('getCustomPrice')
Expand Down

0 comments on commit f009a5f

Please sign in to comment.