当我将新产品模型导入 Akeneo 并想更改系列变体时,我收到以下消息:
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.) [] []
现在我可以通过Pim\Component\Catalog\Updater\ProductModelUpdater
像这样扩展来绕过这个异常:
/**
* @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;
}
}
但我想知道的是(也许 Akeneo 团队的某个人可以回答这个问题)
- 为什么我不允许更改家庭变体?
- 无论如何,这样做可能会产生什么副作用?