Skip to content

Commit

Permalink
fix variant values are missing in export
Browse files Browse the repository at this point in the history
  • Loading branch information
a.laurowski authored Feb 2, 2022
1 parent 3b2488d commit 1c77c5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
## [v2.4.2] - 2022.02.02
### Fix
- Export
- fix variant base values are not exported if FilterAttributes are not configured to be exported from variant level

## [v2.4.1] - 2022.01.28
### Fix
- Category Page
Expand Down Expand Up @@ -397,6 +402,7 @@
### Added
- Feed Export: Export feed file is now available via separate link

[v2.4.2]: https://github.com/FACT-Finder-Web-Components/magento2-module/releases/tag/v2.4.2
[v2.4.1]: https://github.com/FACT-Finder-Web-Components/magento2-module/releases/tag/v2.4.1
[v2.4.0]: https://github.com/FACT-Finder-Web-Components/magento2-module/releases/tag/v2.4.0
[v2.3.3]: https://github.com/FACT-Finder-Web-Components/magento2-module/releases/tag/v2.3.3
Expand Down
14 changes: 8 additions & 6 deletions src/Model/Export/Catalog/Entity/ProductVariation.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ public function toArray(): array
] + $this->configurableData;

list($filterAttributes, $restFields) = $this->extractFilterAttributes($this->fieldprovider->getVariantFields());
$splicedFilterAttributes = str_replace('||', '|', ($this->configurableData['FilterAttributes'] ?? '') . ($filterAttributes ? $filterAttributes->getValue($this->product) : ''));

return $splicedFilterAttributes ? ['FilterAttributes' => $splicedFilterAttributes] : [] + array_reduce($restFields,
function (array $result, FieldInterface $field): array {
return [$field->getName() => $field->getValue($this->product)] + $result;
}, $baseData);
$parentAttributes = $this->configurableData['FilterAttributes'] ?? '';
$variantAttributes = $filterAttributes ? $filterAttributes->getValue($this->product) : '';
$splicedFilterAttributes = str_replace('||', '|', $parentAttributes . $variantAttributes);

return ($splicedFilterAttributes ? ['FilterAttributes' => $splicedFilterAttributes] : [])
+ array_reduce($restFields, function (array $result, FieldInterface $field): array {
return [$field->getName() => $field->getValue($this->product)] + $result;
}, $baseData);
}

public function getProduct(): Product
Expand Down

0 comments on commit 1c77c5c

Please sign in to comment.