Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to override Category entity on Akeneo 3 due to hard-coded form type #9868

Closed
peleq-smile opened this issue Apr 3, 2019 · 4 comments
Closed

Comments

@peleq-smile
Copy link

Hi,

I'm trying to override Category entity to add a new property, using Akeneo CE 3.0.10, and I have some troubles to do it.

I'm following official documentation, more or less because I know it's not always up-to-date.

I did override Category class, that's OK, but override of the Category form is not possible.
That's logic because I've just noticed that the parameter pim_enrich.form.type.category.class doesn't exist anymore ! The used Form Type (Akeneo\Pim\Enrichment\Bundle\Form\Type\CategoryType) is now hard-coded 👎 into this two YAML files :

  • Akeneo/Pim/Enrichment/Bundle/Resources/config/form_types.yml
  • Akeneo/Pim/Enrichment/Bundle/Resources/config/controllers.yml

... whereas in Akeneo 2 it was OK !

There is another issue about extending Category entity : #9833, I have no idea if this is linked or not.

Could you please fix this very shortly ?

Rgds,
Perrine

@peleq-smile
Copy link
Author

Hi,

To go forward, I updated both files by using a parameter for the class (in vendor, please don't judge me so fast... this is just for a training not a real project ^^), to be able to override it and it works.

But after that I was unable to add an MediaType form element for my new "image" property of a category, but this is another problem. I guess it's possible but I just don't know how to do that because there is no other sample of MediaType property with the "old twig front" system into Akeneo :'

BR,
Perrine

@fodie
Copy link

fodie commented Apr 30, 2019

Hi @peleq-smile,
How did you resolve the issue? I am new to symfony

@ghost
Copy link

ghost commented May 29, 2019

Hi @peleq-smile,
I had the same issue with customized category entity when upgrading from 2.3.x to 3.0.x.
As of now it doesn't work following the guide from the official docs https://docs.akeneo.com/3.0/manipulate_pim_data/category/add_new_properties_to_a_category.html#define-the-category-form. As a quick fix I decided to override the service definition of the controller within my own bundle (e.g. in Resources/config/controllers.yml) using the parameterized FormType class (for which you probably have an override in place - following the docs):

    pim_enrich.controller.category_tree.product:
        class: 'Akeneo\Pim\Enrichment\Bundle\Controller\Ui\CategoryTreeController'
        arguments:
            - '@event_dispatcher'
            - '@pim_user.context.user'
            - '@pim_catalog.saver.category'
            - '@pim_catalog.remover.category'
            - '@pim_catalog.factory.category'
            - '@pim_catalog.repository.category'
            - '@oro_security.security_facade'
            - { related_entity: product, form_type: '%pim_enrich.form.type.category.class%', acl: pim_enrich_product, route: pim_enrich }
            - '@pimee_security.repository.category_access'
            - '@security.token_storage'
        calls:
            - [ setContainer, [ '@service_container' ] ]

make sure that the yml-file is properly loaded in Your\Custom\Bundle\DependencyInjection\Extension.php:

    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load("controllers.yml");
        [load your other configs...]
    }

@ghost ghost mentioned this issue May 29, 2019
@Doodoune
Copy link
Contributor

Doodoune commented Jul 4, 2019

Hi @peleq-smile!

We release a new fix of our documentation. It contains a fix for the "how to add a new property to a category" page.

https://docs.akeneo.com/3.0/manipulate_pim_data/category/add_new_properties_to_a_category.html

Please, clean your browser cache to show the new version.

Regards,

@Doodoune Doodoune closed this as completed Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants