我目前正在尝试将可翻译的文本区域添加到描述仪表板中,如下所述:https://docs.akeneo.com/3.2/manipulate_pim_data/category/add_new_properties_to_a_category.html我当前的Akeneo版本是3.2,由于一些架构限制,我现在不能升级到v.4。
我盲目地遵循了上面描述的步骤,但当我运行pim-community-standard % php bin/console doctrine:schema:update --dump-sql --verbose时,我还是得到了这个错误:
In TreeListener.php line 72:
[Gedmo\Exception\UnexpectedValueException]
Tree object class: Akeneo\Pim\Enrichment\Component\Category\Model\Category must have tree metadata at this point这些是我目前的文件:
pim-community-standard/src/Acme/Bundle/CatalogBundle/Entity/CategoryTranslation.php
<?php
namespace Acme\Bundle\CatalogBundle\Entity;
use Akeneo\Pim\Enrichment\Component\Category\Model\CategoryTranslation as BaseCategoryTranslation;
class CategoryTranslation extends BaseCategoryTranslation
{
protected $description;
public function getDescription()
{
return $this->description;
}
public function setDescription($description)
{
$this->description = $description;
return $this;
}
}pim-community-standard/src/Acme/Bundle/CatalogBundle/Entity/Category.php
<?php
namespace Acme\Bundle\CatalogBundle\Entity;
use Akeneo\Pim\Enrichment\Component\Category\Model\Category as BaseCategory;
class Category extends BaseCategory
{
public function getDescription()
{
$translated = ($this->getTranslation()) ? $this->getTranslation()->getDescription() : null;
return ($translated !== '' && $translated !== null) ? $translated : '['.$this->getCode().']';
}
public function setDescription($description)
{
$this->getTranslation()->setDescription($description);
return $this;
}
public function getTranslationFQCN()
{
return CategoryTranslation::class;
}
}pim-community-standard/src/Acme/Bundle/CatalogBundle/Resources/config/entities.yml
parameters:
pim_catalog.entity.category.class: Acme\Bundle\CatalogBundle\Entity\Category
pim_catalog.entity.category_translation.class: Acme\Bundle\CatalogBundle\Entity\CategoryTranslationpim-community-standard/src/Acme/Bundle/CatalogBundle/DependencyInjection/AcmeCatalogExtension.php
<?php
// https://stackoverflow.com/questions/45730301/error-on-override-akeneo-entity
// https://github.com/akeneo/pim-community-dev/issues/7509
namespace Acme\Bundle\CatalogBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Extension\Extension;
class AcmeCatalogExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('entities.yml');
}
}我在pim-community-standard/app/config/config.yml的底部添加了以下代码
akeneo_storage_utils:
mapping_overrides:
-
original: Akeneo\Pim\Enrichment\Component\Category\Model\Category
override: Acme\Bundle\CatalogBundle\Entity\Category
-
original: Akeneo\Pim\Enrichment\Component\Category\Model\CategoryTranslation
override: Acme\Bundle\CatalogBundle\Entity\CategoryTranslation外加两个.orm.yml文件。下面是我的完整捆绑包文件系统:

实际上,我的新类扩展了我在config.yml中重写的类。所以我不明白为什么我会得到任何错误。请注意,我实际上做了很多试验和错误,所以我不确定,以前版本的扩展是否以任何方式缓存?
发布于 2020-12-03 19:48:31
需要在/app/config/AppKernel.php中注册AcmeCatalogBundle,如下所示:
protected function registerProjectBundles()
{
return [
// your app bundles should be registered here
new \Acme\Bundle\CatalogBundle\AcmeCatalogBundle(),
];
}https://stackoverflow.com/questions/65094698
复制相似问题