Skip to content

11832: Create order (on Customer edit page) - not working from admin environment #11952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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