Skip to content

Commit

Permalink
⏫ Forwardport of #11952 to 2.3-develop branch
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
magento-engcom-team committed Jan 23, 2018
1 parent 8e77e2f commit dce1c66
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,22 @@ public function convertPrice($value, $format = true)
)
: $this->priceCurrency->convert($value, $this->getStore());
}

/**
* If item is quote or wishlist we need to get product from it.
*
* @param $item
*
* @return Product
*/
public function getProduct($item)
{
if ($item instanceof Product) {
$product = $item;
} else {
$product = $item->getProduct();
}

return $product;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Create;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Pricing\Price\FinalPrice;

class AbstractCreateTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -67,4 +69,34 @@ public function testGetItemPrice()
->willReturn($resultPrice);
$this->assertEquals($resultPrice, $this->model->getItemPrice($this->productMock));
}

/**
* @param $item
*
* @dataProvider getProductDataProvider
*/
public function testGetProduct($item)
{
$product = $this->model->getProduct($item);

self::assertInstanceOf(Product::class, $product);
}

/**
* DataProvider for testGetProduct.
*
* @return array
*/
public function getProductDataProvider()
{
$productMock = $this->createMock(Product::class);

$itemMock = $this->createMock(\Magento\Wishlist\Model\Item::class);
$itemMock->expects($this->once())->method('getProduct')->willReturn($productMock);

return [
[$productMock],
[$itemMock],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@

<?php if ($block->canDisplayPrice()): ?>
<td class="col-price">
<?php if ($block->getDataId() == 'cart'): ?>
<?= /* @noEscape */ $block->getItemPrice($_item->getProduct()) ?>
<?php else: ?>
<?= /* @noEscape */ $block->getItemPrice($_item) ?>
<?php endif; ?>
<?= /* @noEscape */ $block->getItemPrice($block->getProduct($_item)) ?>
</td>
<?php endif; ?>

Expand Down

0 comments on commit dce1c66

Please sign in to comment.