When I import new product models into Akeneo and I want to change the family variant, I get the following message:
15:25:11 WARNING [batch] The Pim\Component\Connector\Processor\Denormalization\ProductModelProcessor was unable to handle the following item:
[family_variant => name_of_family_variant]
(REASON: family_variant: Property "family_variant" cannot be modified, "name_of_family_variant" given.) [] []
Now I am able to bypass this exception by extending Pim\Component\Catalog\Updater\ProductModelUpdater
like so:
/**
* @param ProductModelInterface $productModel
* @param array $data
* @param array $options
* @return $this|\Akeneo\Component\StorageUtils\Updater\ObjectUpdaterInterface
*/
public function update($productModel, array $data, array $options = [])
{
try {
return parent::update($productModel, $data, $options);
} catch (ImmutablePropertyException $exception) {
// Allow changing of the family_variant field for a product model
if ($exception->getPropertyName() === 'family_variant') {
if ($familyVariant = $this->familyVariantRepository->findOneByIdentifier($exception->getPropertyValue())) {
$productModel->setFamilyVariant($familyVariant);
}
}
return $this;
}
}
But what I'm wondering (and perhaps someone of the Akeneo team can answer this)
- Why am I not allowed to change the family variant?
- What could be the possible side-effects of doing it anyway?