Skip to content

Commit

Permalink
ACP-4649 Fixed product attribute merging. (#11257)
Browse files Browse the repository at this point in the history
ACP-4649 Fixed product attribute merging.
  • Loading branch information
vol4onok authored Dec 19, 2024
1 parent 1b6ed25 commit cb0bbda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ protected function mergeLocalizedAttributesData(
$productConcreteLocalizedAttributesTransfer->fromArray($concreteAttributes, true);

$productConcreteLocalizedAttributesTransfer->setAttributes(
array_unique(
array_merge(
$productAbstractLocalizedAttributesTransfer->getAttributes(),
$productConcreteLocalizedAttributesTransfer->getAttributes(),
),
array_merge(
$productAbstractLocalizedAttributesTransfer->getAttributes(),
$productConcreteLocalizedAttributesTransfer->getAttributes(),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ public function testProductConcreteLocalizedAttributesNestedAttributesExtendedWi
// Arrange
$productConcreteLocalizedAttribute = (new LocalizedAttributesTransfer())
->setLocale((new LocaleTransfer())->setIdLocale(1))
->setAttributes(['red', 'green'])
->setAttributes(['color' => 'black', 'pack' => 'box', 'system' => ['Windows', 'Linux']])
->toArray();

$productAbstractLocalizedAttribute = (new LocalizedAttributesTransfer())
->setLocale((new LocaleTransfer())->setIdLocale(1))
->setAttributes(['green', 'blue'])
->setAttributes(['color' => 'red', 'material' => 'wood'])
->toArray();

$productConcrete = (new ProductConcreteTransfer())->fromArray(['fkProductAbstract' => 1, 'localizedAttributes' => [$productConcreteLocalizedAttribute]]);
Expand All @@ -229,6 +229,6 @@ public function testProductConcreteLocalizedAttributesNestedAttributesExtendedWi
);

// Assert
$this->assertEquals(['green', 'blue', 'red'], $productConcreteCollection[0]->getLocalizedAttributes()[0]->getAttributes());
$this->assertEquals(['color' => 'black', 'pack' => 'box', 'material' => 'wood', 'system' => ['Windows', 'Linux']], $productConcreteCollection[0]->getLocalizedAttributes()[0]->getAttributes());
}
}

0 comments on commit cb0bbda

Please sign in to comment.