webgriffe/SyliusAkeneoPlugin

Wrong (?) taxon handling in product import

Closed this issue · 0 comments

Here:

private function handleTaxons(ProductInterface $product, array $akeneoProduct): void
{
$taxons = $this->taxonsResolver->resolve($akeneoProduct);
foreach ($taxons as $taxon) {
if ($product->hasTaxon($taxon)) {
continue;
}
$productTaxon = $this->productTaxonFactory->createNew();
Assert::isInstanceOf($productTaxon, ProductTaxonInterface::class);
/** @var ProductTaxonInterface $productTaxon */
$productTaxon->setTaxon($taxon);
$productTaxon->setPosition(0);
$product->addProductTaxon($productTaxon);
}
}

When handling taxons we only add resolved taxons to the product without removing those that were previously associated.

IMHO it's a bug.