9
9
10
10
use Magento \Framework \DataObject ;
11
11
use Magento \Framework \DataObject \Factory as ObjectFactory ;
12
- use Magento \Framework \Serialize \Serializer \Json ;
13
- use Magento \GroupedProduct \Api \Data \GroupedOptionsInterface ;
14
- use Magento \GroupedProduct \Api \Data \GroupedOptionsInterfaceFactory ;
15
12
use Magento \GroupedProduct \Model \Product \Type \Grouped ;
16
13
use Magento \Quote \Api \Data as QuoteApi ;
17
14
use Magento \Quote \Api \Data \CartItemInterface ;
@@ -29,16 +26,6 @@ class CartItemProcessor implements CartItemProcessorInterface
29
26
*/
30
27
private $ objectFactory ;
31
28
32
- /**
33
- * @var GroupedOptionsInterface
34
- */
35
- private $ groupedOptionFactory ;
36
-
37
- /**
38
- * @var Json
39
- */
40
- private $ jsonSerializer ;
41
-
42
29
/**
43
30
* @var QuoteApi\ProductOptionExtensionFactory
44
31
*/
@@ -56,21 +43,15 @@ class CartItemProcessor implements CartItemProcessorInterface
56
43
57
44
/**
58
45
* @param ObjectFactory $objectFactory
59
- * @param GroupedOptionsInterfaceFactory $groupedOptionFactory
60
- * @param Json $jsonSerializer
61
46
* @param QuoteApi\ProductOptionExtensionFactory $productOptionExtensionFactory
62
47
* @param QuoteApi\ProductOptionInterfaceFactory $productOptionFactory
63
48
*/
64
49
public function __construct (
65
50
ObjectFactory $ objectFactory ,
66
- GroupedOptionsInterfaceFactory $ groupedOptionFactory ,
67
- Json $ jsonSerializer ,
68
51
QuoteApi \ProductOptionExtensionFactory $ productOptionExtensionFactory ,
69
52
QuoteApi \ProductOptionInterfaceFactory $ productOptionFactory
70
53
) {
71
54
$ this ->objectFactory = $ objectFactory ;
72
- $ this ->groupedOptionFactory = $ groupedOptionFactory ;
73
- $ this ->jsonSerializer = $ jsonSerializer ;
74
55
$ this ->productOptionExtensionFactory = $ productOptionExtensionFactory ;
75
56
$ this ->productOptionFactory = $ productOptionFactory ;
76
57
}
@@ -83,21 +64,19 @@ public function __construct(
83
64
*/
84
65
public function convertToBuyRequest (CartItemInterface $ cartItem ): ?DataObject
85
66
{
86
- $ extensionAttributes = $ cartItem ->getProductOption ()
87
- ? $ cartItem ->getProductOption ()->getExtensionAttributes ()
88
- : null ;
89
- if ($ extensionAttributes ) {
90
- $ groupedOptions = $ extensionAttributes ->getGroupedOptions ();
91
- if ($ groupedOptions ) {
92
- $ this ->groupedOptions = $ groupedOptions ;
93
- $ requestData = [];
94
-
95
- foreach ($ groupedOptions as $ item ) {
96
- $ requestData [self ::SUPER_GROUP_CODE ][$ item ->getId ()] = $ item ->getQty ();
97
- }
98
-
99
- return $ this ->objectFactory ->create ($ requestData );
67
+ if ($ cartItem ->getProductOption ()
68
+ && $ cartItem ->getProductOption ()->getExtensionAttributes ()
69
+ && $ cartItem ->getProductOption ()->getExtensionAttributes ()->getGroupedOptions ()
70
+ ) {
71
+ $ groupedOptions = $ cartItem ->getProductOption ()->getExtensionAttributes ()->getGroupedOptions ();
72
+ $ this ->groupedOptions = $ groupedOptions ;
73
+
74
+ $ requestData = [];
75
+ foreach ($ groupedOptions as $ item ) {
76
+ $ requestData [self ::SUPER_GROUP_CODE ][$ item ->getId ()] = $ item ->getQty ();
100
77
}
78
+
79
+ return $ this ->objectFactory ->create ($ requestData );
101
80
}
102
81
103
82
return null ;
0 commit comments