@@ -31,7 +31,9 @@ public function prepareProductAttributes(Product $product, array $productData, a
31
31
$ attributeList = $ product ->getAttributes ();
32
32
foreach ($ productData as $ attributeCode => $ attributeValue ) {
33
33
if (!isset ($ useDefaults [$ attributeCode ]) || $ useDefaults [$ attributeCode ] === '1 ' ) {
34
- $ productData = $ this ->prepareUselessAttributes ($ product , $ attributeCode , $ attributeValue , $ productData );
34
+ if ($ attributeValue === '' && (bool )$ product ->getData ($ attributeCode ) === (bool )$ attributeValue ) {
35
+ unset($ productData [$ attributeCode ]);
36
+ }
35
37
}
36
38
37
39
if (isset ($ useDefaults [$ attributeCode ]) && $ useDefaults [$ attributeCode ] === '1 ' ) {
@@ -43,6 +45,12 @@ public function prepareProductAttributes(Product $product, array $productData, a
43
45
return $ productData ;
44
46
}
45
47
48
+ /**
49
+ * @param Product $product
50
+ * @param string $attributeCode
51
+ * @param array $productData
52
+ * @return array
53
+ */
46
54
private function prepareConfigData (Product $ product , $ attributeCode , array $ productData ): array
47
55
{
48
56
// UI component sends value even if field is disabled, so 'Use Config Settings' must be reset to false
@@ -53,19 +61,12 @@ private function prepareConfigData(Product $product, $attributeCode, array $prod
53
61
return $ productData ;
54
62
}
55
63
56
- private function prepareUselessAttributes (
57
- Product $ product ,
58
- $ attributeCode ,
59
- $ attributeValue ,
60
- array $ productData
61
- ): array {
62
- if ($ attributeValue === '' && (bool )$ product ->getData ($ attributeCode ) === (bool )$ attributeValue ) {
63
- unset($ productData [$ attributeCode ]);
64
- }
65
-
66
- return $ productData ;
67
- }
68
-
64
+ /**
65
+ * @param array $attributeList
66
+ * @param string $attributeCode
67
+ * @param array $productData
68
+ * @return array
69
+ */
69
70
private function prepareDefaultData (array $ attributeList , $ attributeCode , array $ productData ): array
70
71
{
71
72
if (isset ($ attributeList [$ attributeCode ])) {
0 commit comments