File tree Expand file tree Collapse file tree 9 files changed +155
-13
lines changed
Customer/view/frontend/templates/widget
Model/ResourceModel/Order Expand file tree Collapse file tree 9 files changed +155
-13
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ $middle = $block->showMiddlename();
30
30
$ suffix = $ block ->showSuffix ();
31
31
?>
32
32
33
- <?php if ($ prefix || $ middle || $ suffix && !$ block ->getNoWrap ()): ?>
33
+ <?php if (( $ prefix || $ middle || $ suffix) && !$ block ->getNoWrap ()): ?>
34
34
<div class="field required fullname <?php /* @escapeNotVerified */ echo $ block ->getContainerClassName () ?> ">
35
35
<label for="<?php /* @escapeNotVerified */ echo $ block ->getFieldId ('firstname ' ) ?> " class="label">
36
36
<span><?php /* @escapeNotVerified */ echo __ ('Name ' ) ?> </span>
@@ -139,7 +139,7 @@ $suffix = $block->showSuffix();
139
139
</div>
140
140
<?php endif ; ?>
141
141
142
- <?php if ($ prefix || $ middle || $ suffix && !$ block ->getNoWrap ()): ?>
142
+ <?php if (( $ prefix || $ middle || $ suffix) && !$ block ->getNoWrap ()): ?>
143
143
</div>
144
144
</fieldset>
145
145
</div>
Original file line number Diff line number Diff line change @@ -35,14 +35,14 @@ class History extends \Magento\Framework\View\Element\Template
35
35
36
36
/**
37
37
* @param \Magento\Framework\View\Element\Template\Context $context
38
- * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
38
+ * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface $orderCollectionFactory
39
39
* @param \Magento\Customer\Model\Session $customerSession
40
40
* @param \Magento\Sales\Model\Order\Config $orderConfig
41
41
* @param array $data
42
42
*/
43
43
public function __construct (
44
44
\Magento \Framework \View \Element \Template \Context $ context ,
45
- \Magento \Sales \Model \ResourceModel \Order \CollectionFactory $ orderCollectionFactory ,
45
+ \Magento \Sales \Model \ResourceModel \Order \CollectionFactoryInterface $ orderCollectionFactory ,
46
46
\Magento \Customer \Model \Session $ customerSession ,
47
47
\Magento \Sales \Model \Order \Config $ orderConfig ,
48
48
array $ data = []
@@ -71,11 +71,8 @@ public function getOrders()
71
71
return false ;
72
72
}
73
73
if (!$ this ->orders ) {
74
- $ this ->orders = $ this ->_orderCollectionFactory ->create ()->addFieldToSelect (
74
+ $ this ->orders = $ this ->_orderCollectionFactory ->create ($ customerId )->addFieldToSelect (
75
75
'* '
76
- )->addFieldToFilter (
77
- 'customer_id ' ,
78
- $ customerId
79
76
)->addFieldToFilter (
80
77
'status ' ,
81
78
['in ' => $ this ->_orderConfig ->getVisibleOnFrontStatuses ()]
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Sales \Block \Order \History ;
7
+
8
+ /**
9
+ * Sales order history extra container block
10
+ */
11
+ class Container extends \Magento \Framework \View \Element \Template
12
+ {
13
+ /**
14
+ * @var \Magento\Sales\Api\Data\OrderInterface
15
+ */
16
+ private $ order ;
17
+
18
+ /**
19
+ * Set order
20
+ *
21
+ * @param \Magento\Sales\Api\Data\OrderInterface $order
22
+ * @return $this
23
+ */
24
+ public function setOrder (\Magento \Sales \Api \Data \OrderInterface $ order )
25
+ {
26
+ $ this ->order = $ order ;
27
+ return $ this ;
28
+ }
29
+
30
+ /**
31
+ * Get order
32
+ *
33
+ * @return \Magento\Sales\Api\Data\OrderInterface
34
+ */
35
+ private function getOrder ()
36
+ {
37
+ return $ this ->order ;
38
+ }
39
+
40
+ /**
41
+ * Here we set an order for children during retrieving their HTML
42
+ *
43
+ * @param string $alias
44
+ * @param bool $useCache
45
+ * @return string
46
+ * @throws \Magento\Framework\Exception\LocalizedException
47
+ */
48
+ public function getChildHtml ($ alias = '' , $ useCache = false )
49
+ {
50
+ $ layout = $ this ->getLayout ();
51
+ if ($ layout ) {
52
+ $ name = $ this ->getNameInLayout ();
53
+ foreach ($ layout ->getChildBlocks ($ name ) as $ child ) {
54
+ $ child ->setOrder ($ this ->getOrder ());
55
+ }
56
+ }
57
+ return parent ::getChildHtml ($ alias , $ useCache );
58
+ }
59
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Sales \Model \ResourceModel \Order ;
8
+
9
+ /**
10
+ * Class CollectionFactory
11
+ */
12
+ class CollectionFactory implements CollectionFactoryInterface
13
+ {
14
+ /**
15
+ * Object Manager instance
16
+ *
17
+ * @var \Magento\Framework\ObjectManagerInterface
18
+ */
19
+ private $ objectManager = null ;
20
+
21
+ /**
22
+ * Instance name to create
23
+ *
24
+ * @var string
25
+ */
26
+ private $ instanceName = null ;
27
+
28
+ /**
29
+ * Factory constructor
30
+ *
31
+ * @param \Magento\Framework\ObjectManagerInterface $objectManager
32
+ * @param string $instanceName
33
+ */
34
+ public function __construct (
35
+ \Magento \Framework \ObjectManagerInterface $ objectManager ,
36
+ $ instanceName = '\\Magento \\Sales \\Model \\ResourceModel \\Order \\Collection '
37
+ ) {
38
+ $ this ->objectManager = $ objectManager ;
39
+ $ this ->instanceName = $ instanceName ;
40
+ }
41
+
42
+ /**
43
+ * {@inheritdoc}
44
+ */
45
+ public function create ($ customerId = null )
46
+ {
47
+ /** @var \Magento\Sales\Model\ResourceModel\Order\Collection $collection */
48
+ $ collection = $ this ->objectManager ->create ($ this ->instanceName );
49
+
50
+ if ($ customerId ) {
51
+ $ collection ->addFieldToFilter ('customer_id ' , $ customerId );
52
+ }
53
+
54
+ return $ collection ;
55
+ }
56
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Sales \Model \ResourceModel \Order ;
8
+
9
+ /**
10
+ * Class CollectionFactoryInterface
11
+ */
12
+ interface CollectionFactoryInterface
13
+ {
14
+ /**
15
+ * Create class instance with specified parameters
16
+ *
17
+ * @param int $customerId
18
+ * @return \Magento\Sales\Model\ResourceModel\Order\Collection
19
+ */
20
+ public function create ($ customerId = null );
21
+ }
Original file line number Diff line number Diff line change @@ -94,14 +94,10 @@ public function testConstructMethod()
94
94
->with ($ this ->equalTo ('* ' ))
95
95
->will ($ this ->returnSelf ());
96
96
$ orderCollection ->expects ($ this ->at (1 ))
97
- ->method ('addFieldToFilter ' )
98
- ->with ('customer_id ' , $ this ->equalTo ($ customerId ))
99
- ->will ($ this ->returnSelf ());
100
- $ orderCollection ->expects ($ this ->at (2 ))
101
97
->method ('addFieldToFilter ' )
102
98
->with ('status ' , $ this ->equalTo (['in ' => $ statuses ]))
103
99
->will ($ this ->returnSelf ());
104
- $ orderCollection ->expects ($ this ->at (3 ))
100
+ $ orderCollection ->expects ($ this ->at (2 ))
105
101
->method ('setOrder ' )
106
102
->with ('created_at ' , 'desc ' )
107
103
->will ($ this ->returnSelf ());
Original file line number Diff line number Diff line change 80
80
<preference for =" Magento\Sales\Model\Spi\ShipmentResourceInterface" type =" Magento\Sales\Model\ResourceModel\Order\Shipment" />
81
81
<preference for =" Magento\Sales\Model\Spi\ShipmentTrackResourceInterface" type =" Magento\Sales\Model\ResourceModel\Order\Shipment\Track" />
82
82
<preference for =" Magento\Sales\Model\Spi\TransactionResourceInterface" type =" Magento\Sales\Model\ResourceModel\Order\Payment\Transaction" />
83
+ <preference for =" Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface" type =" Magento\Sales\Model\ResourceModel\Order\CollectionFactory" />
83
84
<type name =" Magento\Sales\Model\ResourceModel\Report" shared =" false" />
84
85
<type name =" Magento\Sales\Model\Order\Pdf\Config\Reader" >
85
86
<arguments >
Original file line number Diff line number Diff line change 11
11
<referenceContainer name =" content" >
12
12
<block class =" Magento\Sales\Block\Order\History" name =" sales.order.history" cacheable =" false" >
13
13
<container name =" sales.order.history.info" as =" info" label =" Order History Info" />
14
+ <container name =" sales.order.history.extra.column.header" as =" extra.column.header" label =" Order History Extra Column Header" />
15
+ <block class =" Magento\Sales\Block\Order\History\Container"
16
+ name =" sales.order.history.extra.container" as =" extra.container" >
17
+ <block class =" Magento\Framework\View\Element\Template"
18
+ name =" sales.order.history.extra.container.data" as =" extra.container.data" />
19
+ </block >
14
20
</block >
15
21
<block class =" Magento\Customer\Block\Account\Dashboard" name =" customer.account.link.back" template =" account/link/back.phtml" cacheable =" false" />
16
22
</referenceContainer >
Original file line number Diff line number Diff line change 17
17
<tr>
18
18
<th scope="col" class="col id"><?php /* @escapeNotVerified */ echo __ ('Order # ' ) ?> </th>
19
19
<th scope="col" class="col date"><?php /* @escapeNotVerified */ echo __ ('Date ' ) ?> </th>
20
+ <?php /* @noEscape */ echo $ block ->getChildHtml ('extra.column.header ' );?>
20
21
<th scope="col" class="col shipping"><?php /* @escapeNotVerified */ echo __ ('Ship To ' ) ?> </th>
21
22
<th scope="col" class="col total"><?php /* @escapeNotVerified */ echo __ ('Order Total ' ) ?> </th>
22
23
<th scope="col" class="col status"><?php /* @escapeNotVerified */ echo __ ('Status ' ) ?> </th>
28
29
<tr>
29
30
<td data-th="<?php echo $ block ->escapeHtml (__ ('Order # ' )) ?> " class="col id"><?php /* @escapeNotVerified */ echo $ _order ->getRealOrderId () ?> </td>
30
31
<td data-th="<?php echo $ block ->escapeHtml (__ ('Date ' )) ?> " class="col date"><?php /* @escapeNotVerified */ echo $ block ->formatDate ($ _order ->getCreatedAt ()) ?> </td>
32
+ <?php $ extra = $ block ->getChildBlock ('extra.container ' ); ?>
33
+ <?php if ($ extra ): ?>
34
+ <?php $ extra ->setOrder ($ _order ); ?>
35
+ <?php /* @noEscape */ echo $ extra ->getChildHtml () ?>
36
+ <?php endif ; ?>
31
37
<td data-th="<?php echo $ block ->escapeHtml (__ ('Ship To ' )) ?> " class="col shipping"><?php echo $ _order ->getShippingAddress () ? $ block ->escapeHtml ($ _order ->getShippingAddress ()->getName ()) : ' ' ?> </td>
32
38
<td data-th="<?php echo $ block ->escapeHtml (__ ('Order Total ' )) ?> " class="col total"><?php /* @escapeNotVerified */ echo $ _order ->formatPrice ($ _order ->getGrandTotal ()) ?> </td>
33
39
<td data-th="<?php echo $ block ->escapeHtml (__ ('Status ' )) ?> " class="col status"><?php /* @escapeNotVerified */ echo $ _order ->getStatusLabel () ?> </td>
You can’t perform that action at this time.
0 commit comments