Skip to content

Commit ccc1c6f

Browse files
Fix N/A attributes, remove empty attributes
1 parent 4cdb0ac commit ccc1c6f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Model/Resolver/Products/DataPostProcessor/Attributes.php

+8-11
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ protected function appendWithValue(
128128

129129
// Remove all empty attributes
130130
if (!$attributeValue) {
131-
// If attribute does not contain both value nor options then we remove it from output
132-
if (!isset($productAttributes[$productId][$attributeCode]) ||
133-
!$productAttributes[$productId][$attributeCode]['attribute_options']) {
134-
unset($productAttributes[$productId][$attributeCode]);
135-
}
136131
continue;
137132
}
138133

@@ -200,6 +195,8 @@ protected function appendWithOptions(
200195
!isset($productAttributes[$id][$key]['attribute_value'])
201196
&& !count($variantAttributeValues)
202197
) {
198+
// Remove attribute if it has no value and empty options
199+
unset($productAttributes[$id][$key]);
203200
continue;
204201
}
205202

@@ -376,6 +373,12 @@ public function process(
376373
}
377374
}
378375

376+
$this->appendWithValue(
377+
$attributes,
378+
$productIds,
379+
$productAttributes
380+
);
381+
379382
if ($isCollectOptions) {
380383
$this->appendWithOptions(
381384
$attributes,
@@ -385,12 +388,6 @@ public function process(
385388
);
386389
}
387390

388-
$this->appendWithValue(
389-
$attributes,
390-
$productIds,
391-
$productAttributes
392-
);
393-
394391
return function (&$productData) use ($productAttributes) {
395392
if (!isset($productData['entity_id'])) {
396393
return;

0 commit comments

Comments
 (0)