Skip to content

Commit af7b4e1

Browse files
committed
Resolved Semantic version checker Test Issue
1 parent 6b15169 commit af7b4e1

File tree

5 files changed

+61
-43
lines changed

5 files changed

+61
-43
lines changed

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

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
use Magento\Catalog\Model\Product\Type\AbstractType;
99
use Magento\Framework\Serialize\Serializer\Json;
10-
use Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory;
11-
use Magento\Sales\Api\Data\OrderItemInterface;
1210

1311
/**
1412
* Order item render block
@@ -22,31 +20,23 @@ class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer
2220
*/
2321
private $serializer;
2422

25-
/**
26-
* @var CollectionFactory
27-
*/
28-
private $itemCollectionFactory;
2923

3024
/**
3125
* @param \Magento\Framework\View\Element\Template\Context $context
3226
* @param \Magento\Framework\Stdlib\StringUtils $string
3327
* @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory
3428
* @param array $data
3529
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
36-
* @param \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $itemCollectionFactory
3730
*/
3831
public function __construct(
3932
\Magento\Framework\View\Element\Template\Context $context,
4033
\Magento\Framework\Stdlib\StringUtils $string,
4134
\Magento\Catalog\Model\Product\OptionFactory $productOptionFactory,
4235
array $data = [],
43-
Json $serializer = null,
44-
CollectionFactory $itemCollectionFactory = null
36+
Json $serializer = null
4537
) {
4638
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
4739
->get(Json::class);
48-
$this->itemCollectionFactory = $itemCollectionFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
49-
->get(CollectionFactory::class);
5040

5141
parent::__construct($context, $string, $productOptionFactory, $data);
5242
}
@@ -232,34 +222,4 @@ public function getItemPrice($item)
232222
$block->setItem($item);
233223
return $block->toHtml();
234224
}
235-
236-
/**
237-
* Get Bundle Order Item Collection.
238-
*
239-
* @param int $orderId
240-
* @param int $parentId
241-
*
242-
* @return array|null
243-
*/
244-
public function getOrderItems(int $orderId, int $parentId): ?array
245-
{
246-
$collection = $this->itemCollectionFactory->create();
247-
$collection->setOrderFilter($orderId);
248-
$collection->addFieldToFilter(
249-
[OrderItemInterface::ITEM_ID, OrderItemInterface::PARENT_ITEM_ID],
250-
[
251-
['eq' => $parentId],
252-
['eq' => $parentId]
253-
]
254-
);
255-
256-
$items = [];
257-
258-
foreach ($collection ?? [] as $item) {
259-
$items[] = $item;
260-
}
261-
$collection->clear();
262-
263-
return $items;
264-
}
265225
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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;
9+
10+
use Magento\Framework\Serialize\Serializer\Json;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Catalog\Block\Product\View as ProductView;
13+
14+
/**
15+
* ViewModel for Bundle Option Block
16+
*/
17+
class ValidateQuantity implements ArgumentInterface
18+
{
19+
/**
20+
* @var Json
21+
*/
22+
private $serializer;
23+
24+
/**
25+
* @var ProductView
26+
*/
27+
private $productView;
28+
29+
/**
30+
* @param Json $serializer
31+
* @param ProductView $productView
32+
*/
33+
public function __construct(
34+
Json $serializer,
35+
ProductView $productView
36+
) {
37+
$this->serializer = $serializer;
38+
$this->productView = $productView;
39+
}
40+
41+
public function getQuantityValidators(): string
42+
{
43+
return $this->serializer->serialize(
44+
$this->productView->getQuantityValidators()
45+
);
46+
}
47+
}

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
// 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 = $block->getOrderItems((int)$parentItem->getOrderId(), (int)$parentItem->getId());
10-
10+
$viewModel = $block->getViewModel();
11+
$items = $viewModel->getOrderItems((int)$parentItem->getOrderId(), (int)$parentItem->getId());
1112
$index = 0;
1213
$prevOptionId = '';
1314
?>

0 commit comments

Comments
 (0)