@@ -167,7 +167,8 @@ protected function convertSwatchToDropdown(Attribute $attribute)
167167 if (!empty ($ additionalData )) {
168168 $ additionalData = $ this ->serializer ->unserialize ($ additionalData );
169169 if (is_array ($ additionalData ) && isset ($ additionalData [Swatch::SWATCH_INPUT_TYPE_KEY ])) {
170- $ this ->cleanEavAttributeOptionSwatchValues ($ attribute ->getOption ());
170+ $ option = $ attribute ->getOption () ?: [];
171+ $ this ->cleanEavAttributeOptionSwatchValues ($ option );
171172 unset($ additionalData [Swatch::SWATCH_INPUT_TYPE_KEY ]);
172173 $ attribute ->setData ('additional_data ' , $ this ->serializer ->serialize ($ additionalData ));
173174 }
@@ -246,7 +247,8 @@ protected function saveSwatchParams(Attribute $attribute)
246247 {
247248 if ($ this ->swatchHelper ->isVisualSwatch ($ attribute )) {
248249 $ this ->processVisualSwatch ($ attribute );
249- $ this ->cleanTextSwatchValuesAfterSwitch ($ attribute ->getOptiontext ());
250+ $ attributeOptions = $ attribute ->getOptiontext () ?: [];
251+ $ this ->cleanTextSwatchValuesAfterSwitch ($ attributeOptions );
250252 } elseif ($ this ->swatchHelper ->isTextSwatch ($ attribute )) {
251253 $ this ->processTextualSwatch ($ attribute );
252254 }
@@ -283,10 +285,10 @@ protected function processVisualSwatch(Attribute $attribute)
283285 * Clean swatch option values after switching to the dropdown type.
284286 *
285287 * @param array $attributeOptions
286- * @param null $swatchType
288+ * @param int| null $swatchType
287289 * @throws \Magento\Framework\Exception\LocalizedException
288290 */
289- private function cleanEavAttributeOptionSwatchValues ($ attributeOptions , $ swatchType = null )
291+ private function cleanEavAttributeOptionSwatchValues (array $ attributeOptions , int $ swatchType = null )
290292 {
291293 if (count ($ attributeOptions ) && isset ($ attributeOptions ['value ' ])) {
292294 $ optionsIDs = array_keys ($ attributeOptions ['value ' ]);
@@ -301,7 +303,7 @@ private function cleanEavAttributeOptionSwatchValues($attributeOptions, $swatchT
301303 * @param array $attributeOptions
302304 * @throws \Magento\Framework\Exception\LocalizedException
303305 */
304- private function cleanTextSwatchValuesAfterSwitch ($ attributeOptions )
306+ private function cleanTextSwatchValuesAfterSwitch (array $ attributeOptions )
305307 {
306308 $ this ->cleanEavAttributeOptionSwatchValues ($ attributeOptions , Swatch::SWATCH_TYPE_TEXTUAL );
307309 }
0 commit comments