1

当我将新产品模型导入 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 团队的某个人可以回答这个问题)

  • 为什么我不允许更改家庭变体?
  • 无论如何,这样做可能会产生什么副作用?
4

1 回答 1

1

此功能实际上在 Akeneo 积压中(虽然没有 ETA)。
更改产品型号的系列变体会对目录产生巨大影响,需要进行大量检查:

  • 您应该确保(至少)家庭变体来自同一个先前的家庭
  • 来自其先前父级的值呢?
  • 应该运行一个作业来递归地编辑它的每一个后代,以应用新值/更改家庭变体
  • 如果新的家庭变体没有相同的变体级别计数怎么办?
  • (还有更多用例......)

由于所有这些原因,目前还无法更新产品模型的系列变体。

于 2018-03-16T08:08:49.530 回答