Skip to content

Commit 2a6b1be

Browse files
authored
Merge branch '2.4-develop' into MQE-GL-TicketRoundup-Mar14
2 parents 15c4ed4 + 5b32ab9 commit 2a6b1be

File tree

14 files changed

+249
-47
lines changed

14 files changed

+249
-47
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\ViewModel\Sales\Order\Items;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
use Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory;
12+
use Magento\Sales\Api\Data\OrderItemInterface;
13+
14+
/**
15+
* ViewModel for Bundle Items
16+
*/
17+
class Renderer implements ArgumentInterface
18+
{
19+
/**
20+
* @var CollectionFactory
21+
*/
22+
private $itemCollectionFactory;
23+
24+
/**
25+
* @param CollectionFactory $itemCollectionFactory
26+
*/
27+
public function __construct(
28+
CollectionFactory $itemCollectionFactory
29+
) {
30+
$this->itemCollectionFactory = $itemCollectionFactory;
31+
}
32+
33+
/**
34+
* Get Bundle Order Item Collection.
35+
*
36+
* @param int $orderId
37+
* @param int $parentId
38+
*
39+
* @return array|null
40+
*/
41+
public function getOrderItems(int $orderId, int $parentId): ?array
42+
{
43+
$collection = $this->itemCollectionFactory->create();
44+
$collection->setOrderFilter($orderId);
45+
$collection->addFieldToFilter(
46+
[OrderItemInterface::ITEM_ID, OrderItemInterface::PARENT_ITEM_ID],
47+
[
48+
['eq' => $parentId],
49+
['eq' => $parentId]
50+
]
51+
);
52+
53+
$items = [];
54+
55+
foreach ($collection ?? [] as $item) {
56+
$items[] = $item;
57+
}
58+
$collection->clear();
59+
60+
return $items;
61+
}
62+
}

app/code/Magento/Bundle/view/frontend/layout/sales_order_item_renderers.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
<referenceBlock name="sales.order.items.renderers">
1111
<block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" name="sales.order.items.renderers.bundle" as="bundle" template="Magento_Bundle::sales/order/items/renderer.phtml"/>
1212
</referenceBlock>
13+
<referenceBlock name="sales.order.items.renderers.bundle">
14+
<arguments>
15+
<argument name="view_model" xsi:type="object">Magento\Bundle\ViewModel\Sales\Order\Items\Renderer</argument>
16+
</arguments>
17+
</referenceBlock>
1318
</body>
1419
</page>

app/code/Magento/Bundle/view/frontend/layout/sales_order_print_renderers.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
<referenceBlock name="sales.order.print.renderers">
1111
<block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" name="sales.order.print.renderers.bundle" as="bundle" template="Magento_Bundle::sales/order/items/renderer.phtml"/>
1212
</referenceBlock>
13+
<referenceBlock name="sales.order.print.renderers.bundle">
14+
<arguments>
15+
<argument name="view_model" xsi:type="object">Magento\Bundle\ViewModel\Sales\Order\Items\Renderer</argument>
16+
</arguments>
17+
</referenceBlock>
1318
</body>
1419
</page>

app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,51 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
6+
// phpcs:disable Magento2.Templates.ThisInTemplate
77
/** @var $block \Magento\Bundle\Block\Sales\Order\Items\Renderer */
8+
/** @var $viewModel \Magento\Bundle\ViewModel\Sales\Order\Items\Renderer */
89
$parentItem = $block->getItem();
9-
$items = array_merge([$parentItem], $parentItem->getChildrenItems());
10+
$viewModel = $block->getViewModel();
11+
$items = $viewModel->getOrderItems((int)$parentItem->getOrderId(), (int)$parentItem->getId());
1012
$index = 0;
1113
$prevOptionId = '';
1214
?>
1315

14-
<?php foreach ($items as $item) : ?>
16+
<?php foreach ($items as $item): ?>
1517

1618
<?php if ($block->getItemOptions()
1719
|| $parentItem->getDescription()
1820
|| $this->helper(Magento\GiftMessage\Helper\Message::class)->isMessagesAllowed('order_item', $parentItem)
19-
&& $parentItem->getGiftMessageId()) : ?>
21+
&& $parentItem->getGiftMessageId()): ?>
2022
<?php $showLastRow = true; ?>
21-
<?php else : ?>
23+
<?php else: ?>
2224
<?php $showLastRow = false; ?>
2325
<?php endif; ?>
2426

25-
<?php if ($item->getParentItem()) : ?>
27+
<?php if ($item->getParentItem()): ?>
2628
<?php $attributes = $block->getSelectionAttributes($item) ?>
27-
<?php if ($prevOptionId != $attributes['option_id']) : ?>
29+
30+
<?php if (isset($attributes['option_id']) && $prevOptionId != $attributes['option_id']): ?>
2831
<tr class="options-label">
2932
<td class="col label" colspan="5"><?= $block->escapeHtml($attributes['option_label']); ?></td>
3033
</tr>
3134
<?php $prevOptionId = $attributes['option_id'] ?>
3235
<?php endif; ?>
3336
<?php endif; ?>
3437
<tr id="order-item-row-<?= /* @noEscape */ $item->getId() ?>"
35-
class="<?php if ($item->getParentItem()) : ?>
38+
class="<?php if ($item->getParentItem()): ?>
3639
item-options-container
37-
<?php else : ?>
40+
<?php else: ?>
3841
item-parent
3942
<?php endif; ?>"
40-
<?php if ($item->getParentItem()) : ?>
41-
data-th="<?= $block->escapeHtmlAttr($attributes['option_label']); ?>"
43+
<?php if ($item->getParentItem()): ?>
44+
data-th="<?= $block->escapeHtmlAttr($attributes['option_label'] ?? ''); ?>"
4245
<?php endif; ?>>
43-
<?php if (!$item->getParentItem()) : ?>
46+
<?php if (!$item->getParentItem()): ?>
4447
<td class="col name" data-th="<?= $block->escapeHtmlAttr(__('Product Name')); ?>">
4548
<strong class="product name product-item-name"><?= $block->escapeHtml($item->getName()); ?></strong>
4649
</td>
47-
<?php else : ?>
50+
<?php else: ?>
4851
<td class="col value" data-th="<?= $block->escapeHtmlAttr(__('Product Name')); ?>">
4952
<?= $block->getValueHtml($item); ?>
5053
</td>
@@ -53,82 +56,82 @@ $prevOptionId = '';
5356
<?= /* @noEscape */ $block->prepareSku($item->getSku()); ?>
5457
</td>
5558
<td class="col price" data-th="<?= $block->escapeHtmlAttr(__('Price')); ?>">
56-
<?php if (!$item->getParentItem()) : ?>
59+
<?php if (!$item->getParentItem()): ?>
5760
<?= /* @noEscape */ $block->getItemPriceHtml(); ?>
58-
<?php else : ?>
61+
<?php else: ?>
5962
&nbsp;
6063
<?php endif; ?>
6164
</td>
6265
<td class="col qty" data-th="<?= $block->escapeHtmlAttr(__('Quantity')); ?>">
6366
<?php if (($item->getParentItem() && $block->isChildCalculated()) ||
6467
(!$item->getParentItem() && !$block->isChildCalculated()) ||
65-
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())) : ?>
68+
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())): ?>
6669
<ul class="items-qty">
6770
<?php endif; ?>
6871
<?php if (($item->getParentItem() && $block->isChildCalculated()) ||
69-
(!$item->getParentItem() && !$block->isChildCalculated())) : ?>
70-
<?php if ($item->getQtyOrdered() > 0) : ?>
72+
(!$item->getParentItem() && !$block->isChildCalculated())): ?>
73+
<?php if ($item->getQtyOrdered() > 0): ?>
7174
<li class="item">
7275
<span class="title"><?= $block->escapeHtml(__('Ordered')); ?></span>
7376
<span class="content"><?= /* @noEscape */ $item->getQtyOrdered() * 1; ?></span>
7477
</li>
7578
<?php endif; ?>
76-
<?php if ($item->getQtyShipped() > 0 && !$block->isShipmentSeparately()) : ?>
79+
<?php if ($item->getQtyShipped() > 0 && !$block->isShipmentSeparately()): ?>
7780
<li class="item">
7881
<span class="title"><?= $block->escapeHtml(__('Shipped')); ?></span>
7982
<span class="content"><?= /* @noEscape */ $item->getQtyShipped() * 1; ?></span>
8083
</li>
8184
<?php endif; ?>
82-
<?php if ($item->getQtyCanceled() > 0) : ?>
85+
<?php if ($item->getQtyCanceled() > 0): ?>
8386
<li class="item">
8487
<span class="title"><?= $block->escapeHtml(__('Canceled')); ?></span>
8588
<span class="content"><?= /* @noEscape */ $item->getQtyCanceled() * 1; ?></span>
8689
</li>
8790
<?php endif; ?>
88-
<?php if ($item->getQtyRefunded() > 0) : ?>
91+
<?php if ($item->getQtyRefunded() > 0): ?>
8992
<li class="item">
9093
<span class="title"><?= $block->escapeHtml(__('Refunded')); ?></span>
9194
<span class="content"><?= /* @noEscape */ $item->getQtyRefunded() * 1; ?></span>
9295
</li>
9396
<?php endif; ?>
94-
<?php elseif ($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately()) : ?>
97+
<?php elseif ($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately()): ?>
9598
<li class="item">
9699
<span class="title"><?= $block->escapeHtml(__('Shipped')); ?></span>
97100
<span class="content"><?= /* @noEscape */ $item->getQtyShipped() * 1; ?></span>
98101
</li>
99-
<?php else : ?>
102+
<?php else: ?>
100103
<span class="content"><?= /* @noEscape */ $parentItem->getQtyOrdered() * 1; ?></span>
101104
<?php endif; ?>
102105
<?php if (($item->getParentItem() && $block->isChildCalculated()) ||
103106
(!$item->getParentItem() && !$block->isChildCalculated()) ||
104-
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())) :?>
107+
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())):?>
105108
</ul>
106109
<?php endif; ?>
107110
</td>
108111
<td class="col subtotal" data-th="<?= $block->escapeHtmlAttr(__('Subtotal')) ?>">
109-
<?php if (!$item->getParentItem()) : ?>
112+
<?php if (!$item->getParentItem()): ?>
110113
<?= /* @noEscape */ $block->getItemRowTotalHtml(); ?>
111-
<?php else : ?>
114+
<?php else: ?>
112115
&nbsp;
113116
<?php endif; ?>
114117
</td>
115118
</tr>
116119
<?php endforeach; ?>
117120

118-
<?php if ($showLastRow && (($options = $block->getItemOptions()) || $block->escapeHtml($item->getDescription()))) : ?>
121+
<?php if ($showLastRow && (($options = $block->getItemOptions()) || $block->escapeHtml($item->getDescription()))): ?>
119122
<tr>
120123
<td class="col options" colspan="5">
121-
<?php if ($options = $block->getItemOptions()) : ?>
124+
<?php if ($options = $block->getItemOptions()): ?>
122125
<dl class="item-options">
123-
<?php foreach ($options as $option) : ?>
126+
<?php foreach ($options as $option): ?>
124127
<dt><?= $block->escapeHtml($option['label']) ?></dt>
125-
<?php if (!$block->getPrintStatus()) : ?>
128+
<?php if (!$block->getPrintStatus()): ?>
126129
<?php $formattedOptionValue = $block->getFormatedOptionValue($option) ?>
127-
<dd<?php if (isset($formattedOptionValue['full_view'])) : ?>
130+
<dd<?php if (isset($formattedOptionValue['full_view'])): ?>
128131
class="tooltip wrapper"
129132
<?php endif; ?>>
130133
<?= /* @noEscape */ $formattedOptionValue['value'] ?>
131-
<?php if (isset($formattedOptionValue['full_view'])) : ?>
134+
<?php if (isset($formattedOptionValue['full_view'])): ?>
132135
<div class="tooltip content">
133136
<dl class="item options">
134137
<dt><?= $block->escapeHtml($option['label']); ?></dt>
@@ -137,7 +140,7 @@ $prevOptionId = '';
137140
</div>
138141
<?php endif; ?>
139142
</dd>
140-
<?php else : ?>
143+
<?php else: ?>
141144
<dd><?= $block->escapeHtml((isset($option['print_value']) ?
142145
$option['print_value'] :
143146
$option['value'])); ?>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderViewSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@
3030
<element name="productQuantityByRow" type="text" parameterized="true" selector="#my-orders-table tbody:nth-of-type({{index}}) td.qty"/>
3131
<element name="productSubtotalByRow" type="text" parameterized="true" selector="#my-orders-table tbody:nth-of-type({{index}}) td.subtotal"/>
3232
<element name="grandTotal" type="text" selector="//tr[@class='grand_total']//td[@data-th='Grand Total']"/>
33+
<element name="pagerLink" type="text" selector=".pager a.page[href*='order_id/{{orderId}}/?p={{pageNumber}}']" parameterized="true"/>
34+
<element name="itemCountOnPage" type="text" selector="#my-orders-table tbody"/>
3335
</section>
3436
</sections>

app/code/Magento/DirectoryGraphQl/Model/Resolver/Countries.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public function resolve(
5555

5656
$output = [];
5757
foreach ($countries as $country) {
58-
$output[] = $this->dataProcessor->buildOutputDataArray($country, CountryInformationInterface::class);
58+
if (!empty($country->getFullNameLocale())) {
59+
$output[] = $this->dataProcessor->buildOutputDataArray($country, CountryInformationInterface::class);
60+
}
5961
}
6062

6163
return $output;

app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedCsv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function execute()
2828
$fileName = 'shopcart_abandoned.csv';
2929
$content = $this->_view->getLayout()->createBlock(
3030
\Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid::class
31-
)->getCsvFile();
31+
)->getCsv();
3232

3333
return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
3434
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Reports\Test\Unit\Controller\Adminhtml\Report\Shopcart;
9+
10+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid;
12+
use Magento\Reports\Controller\Adminhtml\Report\Shopcart\ExportAbandonedCsv;
13+
use Magento\Reports\Test\Unit\Controller\Adminhtml\Report\AbstractControllerTest;
14+
15+
class ExportAbandonedCsvTest extends AbstractControllerTest
16+
{
17+
/**
18+
* @var ExportAbandonedCsv
19+
*/
20+
protected $exportAbandonedCsv;
21+
22+
/**
23+
* {@inheritDoc}
24+
*/
25+
protected function setUp(): void
26+
{
27+
parent::setUp();
28+
29+
$objectManager = new ObjectManager($this);
30+
$this->exportAbandonedCsv = $objectManager->getObject(
31+
ExportAbandonedCsv::class,
32+
[
33+
'context' => $this->contextMock,
34+
'fileFactory' => $this->fileFactoryMock,
35+
]
36+
);
37+
}
38+
39+
/**
40+
* @return void
41+
*/
42+
public function testExecute()
43+
{
44+
$content = ['export'];
45+
46+
$this->abstractBlockMock
47+
->expects($this->once())
48+
->method('getCsv')
49+
->willReturn($content);
50+
51+
$this->layoutMock
52+
->expects($this->once())
53+
->method('createBlock')
54+
->with(Grid::class)
55+
->willReturn($this->abstractBlockMock);
56+
57+
$this->fileFactoryMock
58+
->expects($this->once())
59+
->method('create')
60+
->with('shopcart_abandoned.csv', $content);
61+
62+
$this->exportAbandonedCsv->execute();
63+
}
64+
}

app/code/Magento/Sales/Block/Order/Items.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
class Items extends AbstractItems
2929
{
3030
/**
31-
* Core registry
32-
*
3331
* @var Registry
3432
*/
3533
protected $_coreRegistry = null;
3634

3735
/**
38-
* Order items per page.
39-
*
4036
* @var int
4137
*/
4238
private $itemsPerPage;
@@ -148,12 +144,11 @@ public function getOrder()
148144
*/
149145
private function preparePager(AbstractBlock $pagerBlock): void
150146
{
151-
$collectionToPager = $this->createItemsCollection();
147+
$collectionToPager = $this->itemCollection;
152148
$collectionToPager->addFieldToFilter('parent_item_id', ['null' => true]);
153-
$pagerBlock->setCollection($collectionToPager);
154-
155149
$pagerBlock->setLimit($this->itemsPerPage);
156150
$pagerBlock->setAvailableLimit([$this->itemsPerPage]);
151+
$pagerBlock->setCollection($collectionToPager);
157152
$pagerBlock->setShowAmounts($this->isPagerDisplayed());
158153
}
159154

0 commit comments

Comments
 (0)