首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Akeneo包创建

Akeneo包创建
EN

Stack Overflow用户
提问于 2020-12-02 00:40:00
回答 1查看 174关注 0票数 0

我目前正在尝试将可翻译的文本区域添加到描述仪表板中,如下所述: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时,我还是得到了这个错误:

代码语言:javascript
复制
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

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<?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

代码语言:javascript
复制
parameters:
    pim_catalog.entity.category.class: Acme\Bundle\CatalogBundle\Entity\Category
    pim_catalog.entity.category_translation.class: Acme\Bundle\CatalogBundle\Entity\CategoryTranslation

pim-community-standard/src/Acme/Bundle/CatalogBundle/DependencyInjection/AcmeCatalogExtension.php

代码语言:javascript
复制
<?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的底部添加了以下代码

代码语言:javascript
复制
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中重写的类。所以我不明白为什么我会得到任何错误。请注意,我实际上做了很多试验和错误,所以我不确定,以前版本的扩展是否以任何方式缓存?

EN

回答 1

Stack Overflow用户

发布于 2020-12-03 19:48:31

需要在/app/config/AppKernel.php中注册AcmeCatalogBundle,如下所示:

代码语言:javascript
复制
protected function registerProjectBundles()
    {
        return [
            // your app bundles should be registered here
            new \Acme\Bundle\CatalogBundle\AcmeCatalogBundle(),
        ];
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65094698

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档