File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed
app/code/Magento/Bundle/ViewModel/Sales/Order/Items Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments