Akeneo bundle creation

I’m currently trying to add a translatable textarea into the description dashboard, as described here: https://docs.akeneo.com/3.2/manipulate_pim_data/category/add_new_properties_to_a_category.html
My current Akeneo version is 3.2, due to some architectural limitations I cannot upgrade right now to v.4.

I slavishly followed the steps described above, still when I run pim-community-standard % php bin/console doctrine:schema:update --dump-sql --verbose I get this error:

In TreeListener.php line 72:
[GedmoExceptionUnexpectedValueException]
Tree object class: AkeneoPimEnrichmentComponentCategoryModelCategory must have tree metadata at this point

These are my files at the moment:

pim-community-standard/src/Acme/Bundle/CatalogBundle/Entity/CategoryTranslation.php:

<?php

namespace AcmeBundleCatalogBundleEntity;

use AkeneoPimEnrichmentComponentCategoryModelCategoryTranslation 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 AcmeBundleCatalogBundleEntity;

use AkeneoPimEnrichmentComponentCategoryModelCategory 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: AcmeBundleCatalogBundleEntityCategory
    pim_catalog.entity.category_translation.class: AcmeBundleCatalogBundleEntityCategoryTranslation

pim-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 AcmeBundleCatalogBundleDependencyInjection;

use SymfonyComponentConfigFileLocator;
use SymfonyComponentDependencyInjectionContainerBuilder;
use SymfonyComponentDependencyInjectionLoader;
use SymfonyComponentDependencyInjectionExtensionExtension;

class AcmeCatalogExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new LoaderYamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('entities.yml');
    }
}

I added this code at the bottom of pim-community-standard/app/config/config.yml

akeneo_storage_utils:
    mapping_overrides:
        -
            original: AkeneoPimEnrichmentComponentCategoryModelCategory
            override: AcmeBundleCatalogBundleEntityCategory
        -
            original: AkeneoPimEnrichmentComponentCategoryModelCategoryTranslation
            override: AcmeBundleCatalogBundleEntityCategoryTranslation

Plus the two .orm.yml files. Here is my full bundle filesystem:

Bundle screenshot

In fact, my new classes extend the same ones I’m overriding in config.yml. So I’m not getting why I’m getting any error.
Note that I actually did a lot of trial and error so I’m not sure, are previous versions of the extensions getting cached in any way?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *