Skip to content
Snippets Groups Projects
Commit c6c1b9f1 authored by Mykola Palamar's avatar Mykola Palamar
Browse files

Merge remote-tracking branch 'origin/develop' into MAGETWO-54689

parents 6f385d77 0d59cf48
Branches
No related merge requests found
......@@ -30,7 +30,7 @@ $middle = $block->showMiddlename();
$suffix = $block->showSuffix();
?>
<?php if ($prefix || $middle || $suffix && !$block->getNoWrap()): ?>
<?php if (($prefix || $middle || $suffix) && !$block->getNoWrap()): ?>
<div class="field required fullname <?php /* @escapeNotVerified */ echo $block->getContainerClassName() ?>">
<label for="<?php /* @escapeNotVerified */ echo $block->getFieldId('firstname') ?>" class="label">
<span><?php /* @escapeNotVerified */ echo __('Name') ?></span>
......@@ -139,7 +139,7 @@ $suffix = $block->showSuffix();
</div>
<?php endif; ?>
<?php if ($prefix || $middle || $suffix && !$block->getNoWrap()): ?>
<?php if (($prefix || $middle || $suffix) && !$block->getNoWrap()): ?>
</div>
</fieldset>
</div>
......
......@@ -5,6 +5,9 @@
*/
namespace Magento\Sales\Block\Order;
use \Magento\Framework\App\ObjectManager;
use \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface;
/**
* Sales order history block
*/
......@@ -33,6 +36,11 @@ class History extends \Magento\Framework\View\Element\Template
/** @var \Magento\Sales\Model\ResourceModel\Order\Collection */
protected $orders;
/**
* @var CollectionFactoryInterface
*/
private $orderCollectionFactory;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
......@@ -62,6 +70,19 @@ class History extends \Magento\Framework\View\Element\Template
$this->pageConfig->getTitle()->set(__('My Orders'));
}
/**
* @return CollectionFactoryInterface
*
* @deprecated
*/
private function getOrderCollectionFactory()
{
if ($this->orderCollectionFactory === null) {
$this->orderCollectionFactory = ObjectManager::getInstance()->get(CollectionFactoryInterface::class);
}
return $this->orderCollectionFactory;
}
/**
* @return bool|\Magento\Sales\Model\ResourceModel\Order\Collection
*/
......@@ -71,11 +92,8 @@ class History extends \Magento\Framework\View\Element\Template
return false;
}
if (!$this->orders) {
$this->orders = $this->_orderCollectionFactory->create()->addFieldToSelect(
$this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
'*'
)->addFieldToFilter(
'customer_id',
$customerId
)->addFieldToFilter(
'status',
['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
......
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sales\Block\Order\History;
/**
* Sales order history extra container block
*/
class Container extends \Magento\Framework\View\Element\Template
{
/**
* @var \Magento\Sales\Api\Data\OrderInterface
*/
private $order;
/**
* Set order
*
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @return $this
*/
public function setOrder(\Magento\Sales\Api\Data\OrderInterface $order)
{
$this->order = $order;
return $this;
}
/**
* Get order
*
* @return \Magento\Sales\Api\Data\OrderInterface
*/
private function getOrder()
{
return $this->order;
}
/**
* Here we set an order for children during retrieving their HTML
*
* @param string $alias
* @param bool $useCache
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getChildHtml($alias = '', $useCache = false)
{
$layout = $this->getLayout();
if ($layout) {
$name = $this->getNameInLayout();
foreach ($layout->getChildBlocks($name) as $child) {
$child->setOrder($this->getOrder());
}
}
return parent::getChildHtml($alias, $useCache);
}
}
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sales\Model\ResourceModel\Order;
/**
* Class CollectionFactory
*/
class CollectionFactory implements CollectionFactoryInterface
{
/**
* Object Manager instance
*
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager = null;
/**
* Instance name to create
*
* @var string
*/
private $instanceName = null;
/**
* Factory constructor
*
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $instanceName
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
$instanceName = '\\Magento\\Sales\\Model\\ResourceModel\\Order\\Collection'
) {
$this->objectManager = $objectManager;
$this->instanceName = $instanceName;
}
/**
* {@inheritdoc}
*/
public function create($customerId = null)
{
/** @var \Magento\Sales\Model\ResourceModel\Order\Collection $collection */
$collection = $this->objectManager->create($this->instanceName);
if ($customerId) {
$collection->addFieldToFilter('customer_id', $customerId);
}
return $collection;
}
}
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sales\Model\ResourceModel\Order;
/**
* Class CollectionFactoryInterface
*/
interface CollectionFactoryInterface
{
/**
* Create class instance with specified parameters
*
* @param int $customerId
* @return \Magento\Sales\Model\ResourceModel\Order\Collection
*/
public function create($customerId = null);
}
......@@ -22,6 +22,16 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
*/
protected $orderCollectionFactory;
/**
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $orderCollectionFactoryInterface;
/**
* @var \Magento\Framework\App\ObjectManager|\PHPUnit_Framework_MockObject_MockObject
*/
private $objectManager;
/**
* @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
*/
......@@ -48,6 +58,14 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
$this->orderCollectionFactory =
$this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\CollectionFactory')
->disableOriginalConstructor()->setMethods(['create'])->getMock();
$this->orderCollectionFactoryInterface =
$this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface::class)
->disableOriginalConstructor()->setMethods(['create'])->getMock();
$this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false);
$this->objectManager->expects($this->any())
->method('get')
->will($this->returnValue($this->orderCollectionFactoryInterface));
\Magento\Framework\App\ObjectManager::setInstance($this->objectManager);
$this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session')
->setMethods(['getCustomerId'])->disableOriginalConstructor()->getMock();
......@@ -94,18 +112,14 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo('*'))
->will($this->returnSelf());
$orderCollection->expects($this->at(1))
->method('addFieldToFilter')
->with('customer_id', $this->equalTo($customerId))
->will($this->returnSelf());
$orderCollection->expects($this->at(2))
->method('addFieldToFilter')
->with('status', $this->equalTo(['in' => $statuses]))
->will($this->returnSelf());
$orderCollection->expects($this->at(3))
$orderCollection->expects($this->at(2))
->method('setOrder')
->with('created_at', 'desc')
->will($this->returnSelf());
$this->orderCollectionFactory->expects($this->atLeastOnce())
$this->orderCollectionFactoryInterface->expects($this->atLeastOnce())
->method('create')
->will($this->returnValue($orderCollection));
$this->pageConfig->expects($this->atLeastOnce())
......
......@@ -80,6 +80,7 @@
<preference for="Magento\Sales\Model\Spi\ShipmentResourceInterface" type="Magento\Sales\Model\ResourceModel\Order\Shipment"/>
<preference for="Magento\Sales\Model\Spi\ShipmentTrackResourceInterface" type="Magento\Sales\Model\ResourceModel\Order\Shipment\Track"/>
<preference for="Magento\Sales\Model\Spi\TransactionResourceInterface" type="Magento\Sales\Model\ResourceModel\Order\Payment\Transaction"/>
<preference for="Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface" type="Magento\Sales\Model\ResourceModel\Order\CollectionFactory"/>
<type name="Magento\Sales\Model\ResourceModel\Report" shared="false"/>
<type name="Magento\Sales\Model\Order\Pdf\Config\Reader">
<arguments>
......
......@@ -11,6 +11,12 @@
<referenceContainer name="content">
<block class="Magento\Sales\Block\Order\History" name="sales.order.history" cacheable="false">
<container name="sales.order.history.info" as="info" label="Order History Info"/>
<container name="sales.order.history.extra.column.header" as="extra.column.header" label="Order History Extra Column Header"/>
<block class="Magento\Sales\Block\Order\History\Container"
name="sales.order.history.extra.container" as="extra.container">
<block class="Magento\Framework\View\Element\Template"
name="sales.order.history.extra.container.data" as="extra.container.data"/>
</block>
</block>
<block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml" cacheable="false"/>
</referenceContainer>
......
......@@ -17,6 +17,7 @@
<tr>
<th scope="col" class="col id"><?php /* @escapeNotVerified */ echo __('Order #') ?></th>
<th scope="col" class="col date"><?php /* @escapeNotVerified */ echo __('Date') ?></th>
<?php /* @noEscape */ echo $block->getChildHtml('extra.column.header');?>
<th scope="col" class="col shipping"><?php /* @escapeNotVerified */ echo __('Ship To') ?></th>
<th scope="col" class="col total"><?php /* @escapeNotVerified */ echo __('Order Total') ?></th>
<th scope="col" class="col status"><?php /* @escapeNotVerified */ echo __('Status') ?></th>
......@@ -28,6 +29,11 @@
<tr>
<td data-th="<?php echo $block->escapeHtml(__('Order #')) ?>" class="col id"><?php /* @escapeNotVerified */ echo $_order->getRealOrderId() ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php /* @escapeNotVerified */ echo $block->formatDate($_order->getCreatedAt()) ?></td>
<?php $extra = $block->getChildBlock('extra.container'); ?>
<?php if ($extra): ?>
<?php $extra->setOrder($_order); ?>
<?php /* @noEscape */ echo $extra->getChildHtml() ?>
<?php endif; ?>
<td data-th="<?php echo $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?php echo $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Order Total')) ?>" class="col total"><?php /* @escapeNotVerified */ echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Status')) ?>" class="col status"><?php /* @escapeNotVerified */ echo $_order->getStatusLabel() ?></td>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment