Skip to content

Commit 593a7fa

Browse files
Merge pull request #14 from AleksandrsKondratjevs/issue-1967
Fix N/A attributes, remove empty attributes
2 parents e27a92b + ccc1c6f commit 593a7fa

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

@@ -378,6 +375,12 @@ public function process(
378375
}
379376
}
380377

378+
$this->appendWithValue(
379+
$attributes,
380+
$productIds,
381+
$productAttributes
382+
);
383+
381384
if ($isCollectOptions) {
382385
$this->appendWithOptions(
383386
$attributes,
@@ -387,12 +390,6 @@ public function process(
387390
);
388391
}
389392

390-
$this->appendWithValue(
391-
$attributes,
392-
$productIds,
393-
$productAttributes
394-
);
395-
396393
return function (&$productData) use ($productAttributes) {
397394
if (!isset($productData['entity_id'])) {
398395
return;

0 commit comments

Comments
 (0)