@@ -82,31 +82,34 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
8282 */
8383 public function processOptions (CartItemInterface $ cartItem )
8484 {
85- $ attributesOption = $ cartItem ->getProduct ()->getCustomOption ('attributes ' );
86- $ selectedConfigurableOptions = $ this ->serializer ->unserialize ($ attributesOption ->getValue ());
85+ $ attributesOption = $ cartItem ->getProduct ()
86+ ->getCustomOption ('attributes ' );
87+ if ($ attributesOption ) {
88+ $ selectedConfigurableOptions = $ this ->serializer ->unserialize ($ attributesOption ->getValue ());
8789
88- if (is_array ($ selectedConfigurableOptions )) {
89- $ configurableOptions = [];
90- foreach ($ selectedConfigurableOptions as $ optionId => $ optionValue ) {
91- /** @var \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface $option */
92- $ option = $ this ->itemOptionValueFactory ->create ();
93- $ option ->setOptionId ($ optionId );
94- $ option ->setOptionValue ($ optionValue );
95- $ configurableOptions [] = $ option ;
96- }
90+ if (is_array ($ selectedConfigurableOptions )) {
91+ $ configurableOptions = [];
92+ foreach ($ selectedConfigurableOptions as $ optionId => $ optionValue ) {
93+ /** @var \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface $option */
94+ $ option = $ this ->itemOptionValueFactory ->create ();
95+ $ option ->setOptionId ($ optionId );
96+ $ option ->setOptionValue ($ optionValue );
97+ $ configurableOptions [] = $ option ;
98+ }
9799
98- $ productOption = $ cartItem ->getProductOption ()
99- ? $ cartItem ->getProductOption ()
100- : $ this ->productOptionFactory ->create ();
100+ $ productOption = $ cartItem ->getProductOption ()
101+ ? $ cartItem ->getProductOption ()
102+ : $ this ->productOptionFactory ->create ();
101103
102- /** @var \Magento\Quote\Api\Data\ProductOptionExtensionInterface $extensibleAttribute */
103- $ extensibleAttribute = $ productOption ->getExtensionAttributes ()
104- ? $ productOption ->getExtensionAttributes ()
105- : $ this ->extensionFactory ->create ();
104+ /** @var \Magento\Quote\Api\Data\ProductOptionExtensionInterface $extensibleAttribute */
105+ $ extensibleAttribute = $ productOption ->getExtensionAttributes ()
106+ ? $ productOption ->getExtensionAttributes ()
107+ : $ this ->extensionFactory ->create ();
106108
107- $ extensibleAttribute ->setConfigurableItemOptions ($ configurableOptions );
108- $ productOption ->setExtensionAttributes ($ extensibleAttribute );
109- $ cartItem ->setProductOption ($ productOption );
109+ $ extensibleAttribute ->setConfigurableItemOptions ($ configurableOptions );
110+ $ productOption ->setExtensionAttributes ($ extensibleAttribute );
111+ $ cartItem ->setProductOption ($ productOption );
112+ }
110113 }
111114 return $ cartItem ;
112115 }
0 commit comments