@@ -938,7 +938,7 @@ public function __construct(
938
938
$ this ->_optionEntity = $ data ['option_entity ' ] ??
939
939
$ optionFactory ->create (['data ' => ['product_entity ' => $ this ]]);
940
940
$ this ->skuStorage = $ skuStorage ?? ObjectManager::getInstance ()
941
- ->get (SkuStorage::class);
941
+ ->get (SkuStorage::class);
942
942
$ this ->_initAttributeSets ()
943
943
->_initTypeModels ()
944
944
->_initSkus ()
@@ -948,7 +948,7 @@ public function __construct(
948
948
$ this ->productRepository = $ productRepository ?? ObjectManager::getInstance ()
949
949
->get (ProductRepositoryInterface::class);
950
950
$ this ->stockItemProcessor = $ stockItemProcessor ?? ObjectManager::getInstance ()
951
- ->get (StockItemProcessorInterface::class);
951
+ ->get (StockItemProcessorInterface::class);
952
952
}
953
953
954
954
/**
@@ -2002,8 +2002,8 @@ private function saveProductMediaGalleryPhase(
2002
2002
private function saveProductAttributesPhase (
2003
2003
array $ rowData ,
2004
2004
int $ rowScope ,
2005
- &$ previousType ,
2006
- &$ prevAttributeSet ,
2005
+ &$ previousType ,
2006
+ &$ prevAttributeSet ,
2007
2007
array &$ attributes
2008
2008
) : void {
2009
2009
$ rowSku = $ rowData [self ::COL_SKU ];
@@ -2836,7 +2836,7 @@ private function prepareNewSkuData($sku)
2836
2836
*
2837
2837
* @return array
2838
2838
*/
2839
- private function _parseAdditionalAttributes ($ rowData )
2839
+ private function _parseAdditionalAttributes (array $ rowData ): array
2840
2840
{
2841
2841
if (empty ($ rowData ['additional_attributes ' ])) {
2842
2842
return $ rowData ;
@@ -2846,7 +2846,7 @@ private function _parseAdditionalAttributes($rowData)
2846
2846
$ rowData [mb_strtolower ($ key )] = $ value ;
2847
2847
}
2848
2848
} else {
2849
- $ rowData = array_merge ($ rowData , $ this ->getAdditionalAttributes ($ rowData[ ' additional_attributes ' ] ));
2849
+ $ rowData = array_merge ($ rowData , $ this ->getAdditionalAttributes ($ rowData ));
2850
2850
}
2851
2851
return $ rowData ;
2852
2852
}
@@ -2860,14 +2860,14 @@ private function _parseAdditionalAttributes($rowData)
2860
2860
* codeN => valueN
2861
2861
* ]
2862
2862
*
2863
- * @param string $additionalAttributes Attributes data that will be parsed
2863
+ * @param array $rowData
2864
2864
* @return array
2865
2865
*/
2866
- private function getAdditionalAttributes ($ additionalAttributes )
2866
+ private function getAdditionalAttributes (array $ rowData ): array
2867
2867
{
2868
2868
return empty ($ this ->_parameters [Import::FIELDS_ENCLOSURE ])
2869
- ? $ this ->parseAttributesWithoutWrappedValues ($ additionalAttributes )
2870
- : $ this ->parseAttributesWithWrappedValues ($ additionalAttributes );
2869
+ ? $ this ->parseAttributesWithoutWrappedValues ($ rowData [ ' additional_attributes ' ], $ rowData [ ' product_type ' ] )
2870
+ : $ this ->parseAttributesWithWrappedValues ($ rowData [ ' additional_attributes ' ] );
2871
2871
}
2872
2872
2873
2873
/**
@@ -2881,9 +2881,10 @@ private function getAdditionalAttributes($additionalAttributes)
2881
2881
*
2882
2882
* @param string $attributesData Attributes data that will be parsed. It keeps data in format:
2883
2883
* code=value,code2=value2...,codeN=valueN
2884
+ * @param string $productType
2884
2885
* @return array
2885
2886
*/
2886
- private function parseAttributesWithoutWrappedValues ($ attributesData)
2887
+ private function parseAttributesWithoutWrappedValues (string $ attributesData, string $ productType ): array
2887
2888
{
2888
2889
$ attributeNameValuePairs = explode ($ this ->getMultipleValueSeparator (), $ attributesData );
2889
2890
$ preparedAttributes = [];
@@ -2894,21 +2895,21 @@ private function parseAttributesWithoutWrappedValues($attributesData)
2894
2895
if (!$ code ) {
2895
2896
continue ;
2896
2897
}
2897
- //concatenate attribute values with last used separator in case of array
2898
- if (is_array ($ preparedAttributes [$ code ])
2899
- && str_contains ($ attributesData , self ::PSEUDO_MULTI_LINE_SEPARATOR )) {
2900
- $ preparedAttributes [$ code ] = implode (
2901
- self ::PSEUDO_MULTI_LINE_SEPARATOR ,
2902
- $ preparedAttributes [$ code ]
2903
- );
2904
- }
2905
2898
$ preparedAttributes [$ code ] .= $ this ->getMultipleValueSeparator () . $ attributeData ;
2906
2899
continue ;
2907
2900
}
2908
2901
list ($ code , $ value ) = explode (self ::PAIR_NAME_VALUE_SEPARATOR , $ attributeData , 2 );
2909
2902
$ code = mb_strtolower ($ code );
2910
- if (str_contains ($ value , self ::PSEUDO_MULTI_LINE_SEPARATOR )) {
2911
- $ value = $ this ->parseMultiselectValues ($ value , self ::PSEUDO_MULTI_LINE_SEPARATOR );
2903
+
2904
+ $ entityTypeModel = $ this ->retrieveProductTypeByName ($ productType );
2905
+ if ($ entityTypeModel ) {
2906
+ $ attrParams = $ entityTypeModel ->retrieveAttributeFromCache ($ code );
2907
+ if (!empty ($ attrParams ) && $ attrParams ['type ' ] == 'multiselect ' ) {
2908
+ $ parsedValue = $ this ->parseMultiselectValues ($ value , self ::PSEUDO_MULTI_LINE_SEPARATOR );
2909
+ if (count ($ parsedValue ) > 1 ) {
2910
+ $ value = $ parsedValue ;
2911
+ }
2912
+ }
2912
2913
}
2913
2914
$ preparedAttributes [$ code ] = $ value ;
2914
2915
}
0 commit comments