Skip to content

Commit 0d151c4

Browse files
Merge forwardport of #11952 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/11952.patch (created by @RomaKis) based on commit(s): 1. eeb7dff Fixed GitHub Issues in 2.3-develop branch: - #11832: Create order (on Customer edit page) - not working from admin environment (reported by @psbhanu)
2 parents 1f7347f + dce1c66 commit 0d151c4

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,22 @@ public function convertPrice($value, $format = true)
160160
)
161161
: $this->priceCurrency->convert($value, $this->getStore());
162162
}
163+
164+
/**
165+
* If item is quote or wishlist we need to get product from it.
166+
*
167+
* @param $item
168+
*
169+
* @return Product
170+
*/
171+
public function getProduct($item)
172+
{
173+
if ($item instanceof Product) {
174+
$product = $item;
175+
} else {
176+
$product = $item->getProduct();
177+
}
178+
179+
return $product;
180+
}
163181
}

app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/AbstractCreateTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Create;
78

9+
use Magento\Catalog\Model\Product;
810
use Magento\Catalog\Pricing\Price\FinalPrice;
911

1012
class AbstractCreateTest extends \PHPUnit\Framework\TestCase
@@ -67,4 +69,34 @@ public function testGetItemPrice()
6769
->willReturn($resultPrice);
6870
$this->assertEquals($resultPrice, $this->model->getItemPrice($this->productMock));
6971
}
72+
73+
/**
74+
* @param $item
75+
*
76+
* @dataProvider getProductDataProvider
77+
*/
78+
public function testGetProduct($item)
79+
{
80+
$product = $this->model->getProduct($item);
81+
82+
self::assertInstanceOf(Product::class, $product);
83+
}
84+
85+
/**
86+
* DataProvider for testGetProduct.
87+
*
88+
* @return array
89+
*/
90+
public function getProductDataProvider()
91+
{
92+
$productMock = $this->createMock(Product::class);
93+
94+
$itemMock = $this->createMock(\Magento\Wishlist\Model\Item::class);
95+
$itemMock->expects($this->once())->method('getProduct')->willReturn($productMock);
96+
97+
return [
98+
[$productMock],
99+
[$itemMock],
100+
];
101+
}
70102
}

app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@
6767

6868
<?php if ($block->canDisplayPrice()): ?>
6969
<td class="col-price">
70-
<?php if ($block->getDataId() == 'cart'): ?>
71-
<?= /* @noEscape */ $block->getItemPrice($_item->getProduct()) ?>
72-
<?php else: ?>
73-
<?= /* @noEscape */ $block->getItemPrice($_item) ?>
74-
<?php endif; ?>
70+
<?= /* @noEscape */ $block->getItemPrice($block->getProduct($_item)) ?>
7571
</td>
7672
<?php endif; ?>
7773

0 commit comments

Comments
 (0)