1

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?
Giel Berkers
  • 2,852
  • 3
  • 39
  • 58

1 Answers1

1

This feature is actually in the Akeneo backlog (no ETA though).
Changing the family variant of a product model is a huge catalog impact and needs a lot of checks:

  • You should ensure (at least) that the family variant is coming from the same previous family
  • What about the values coming from its previous parent?
  • A job should be run to recursively edit every one of its descendant to apply new values / change of family variant
  • What if the new family variant has not the same variant level count?
  • (and a lot more use cases...)

For all these reasons, it's currently not possible to update the family variant of a product model yet.

grena
  • 1,011
  • 1
  • 10
  • 25