Skip to content
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

10128: New Orders not being saved to order grid #12241

Merged
merged 5 commits into from
Nov 25, 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
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function _prepareCollection()
protected function _afterLoadCollection()
{
foreach ($this->getCollection() as $item) {
$item->getCustomer() ?: $item->setCustomer('Guest');
$item->getCustomer() ?: $item->setCustomer($item->getBillingAddress()->getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to get customer name from the Billing Address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ishakhsuvarov, as it is guest, so he has only shipping and billing addresses. I think it is more reasonably to take it from billing than from shipping.
Also I checked the mail message after I had placed order as guest. It also takes name from billing address.

}
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Block\Dashboard\Orders;

use Magento\Backend\Block\Template\Context;

class GridTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Grid
*/
private $block;

protected function setUp()
{
parent::setUp();

$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$block = $this->createMock(\Magento\Backend\Block\Dashboard\Orders\Grid::class);
$layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
$layout->expects($this->atLeastOnce())->method('getChildName')->willReturn('test');
$layout->expects($this->atLeastOnce())->method('getBlock')->willReturn($block);
$context = $objectManager->create(Context::class, ['layout' => $layout]);

$this->block = $objectManager->create(Grid::class, ['context' => $context]);
}

/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testGetPreparedCollection()
{
$collection = $this->block->getPreparedCollection();
foreach ($collection->getItems() as $item) {
if ($item->getIncrementId() == '100000001') {
$this->assertEquals('firstname lastname', $item->getCustomer());
}
}
}
}