ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 4 replies, has 2 voices, and was last updated by  francesco.2015 5 months, 2 weeks ago.

  • Creator
    Topic
  • #35027

    francesco.2015
    Participant

    Hi all,

    I’m new to OroCRM and I have inherited a custom version based on Oro 1.8.2. The project is somehow broken and cannot be upgraded using the migration tool, so I have started a new one based on Oro 1.10.18, starting from the stub OroCRM Application.

    I have written a migration that adds new fields to the orocrm_account table. The migration works and I’m able to clear the cache. Then I have overrided the datagrid.yml and I have also created an Account.php file to extend original Account.php.

    Source code for src/MatchPint/Bundle/DugoutBundleAccount/Entity/Account.php

    Source code for src/MatchPint/Bundle/DugoutBundleAccount/Resources/config/datagrid.yml

    And a routing.yml in the same directory with the following content:

    As I said I’m able to clear the cache, but when I try to load /account url, I get a 500 error. On the prod log I can see:

    [2017-05-31 17:47:34] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: “An exception has been thrown during the rendering of a template (“No mapping found for field ‘areaManager’ on class ‘OroCRM\Bundle\AccountBundle\Entity\Account’.”) in “/var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig” at line 44.” at /var/www/orocrm/vendor/twig/twig/lib/Twig/Template.php line 182 {“exception”:”[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\”No mapping found for field ‘areaManager’ on class ‘OroCRM\\Bundle\\AccountBundle\\Entity\\Account’.\”) in \”/var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig\” at line 44. at /var/www/orocrm/vendor/twig/twig/lib/Twig/Template.php:182, Doctrine\\ORM\\Mapping\\MappingException(code: 0): No mapping found for field ‘areaManager’ on class ‘OroCRM\\Bundle\\AccountBundle\\Entity\\Account’. at /var/www/orocrm/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:163)”} []

    I didn’t override this template: /var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig

    So I have no idea where this error is coming from. Any hint?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #35030

    mmiasnikov
    Oro Core

    Hi, @francesco.2015!

    Please, take a look at @vova_soroka’s message at the thread https://www.orocrm.com/forums/topic/add-custom-field-into-orocrm-entity#post-4214.

    As I understand, it’s exactly answering to your question (you don’t need to create your own new Account class to customize exist Account entity).

    If you’ll still have questions, let me know.

    Regards.

    #35031

    francesco.2015
    Participant

    Hi @mmiasnikov,

    my bad, the Account class doesn’t extend OroCRM\Bundle\AccountBundle\Entity\Account, but instead it extends OroCRM\Bundle\AccountBundle\Model\ExtendAccount. It’s basically the same OroCRM is doing. Is that not the properly way to do that?

    #35045

    mmiasnikov
    Oro Core

    @francesco.2015, if you wanted just add new field to Account entity, it was enough to create a migration
    and run command $ php app/console oro:migration:load --force (as described in https://www.orocrm.com/documentation/2.0/book/entities#creating-extended-entities manual, for example).

    The Extended Entity functional doesn’t expect using the “single table inheritance”-like entities. But, actually, you don’t need it.

    Please, take a look at https://www.orocrm.com/documentation/2.0/book/entities#creating-extended-entities article and feel free to ask more questions, if you’ll still have them.

    #35071

    francesco.2015
    Participant

    Hi @mmiasnikov,

    as I said I have inherited this project and I don’t intend rebuild everything from scratch, I want to reuse as much code as possible.

    In the original code of the bundle I’m trying to upgrade, there is a class Account which extends ExtendAccount and implements the following interfaces: EmailHolderInterface, NameInterface, Taggable.
    In particular there is a variable $areaManager with annotations to create a relation between the new field mp_area_manager_id and the orocrm_contact entity.

    The migration works, in fact when I run the migration load command (as follow) it alters the orocrm_account table creating new fields.

    The problem is that, when I try to load the page “/account” I get an exception:

    [2017-06-05 15:01:40] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: “An exception has been thrown during the rendering of a template (“No mapping found for field ‘areaManager’ on class ‘OroCRM\Bundle\AccountBundle\Entity\Account’.”) in “/var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig” at line 44.” at /var/www/orocrm/vendor/twig/twig/lib/Twig/Template.php line 182 {“exception”:”[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\”No mapping found for field ‘areaManager’ on class ‘OroCRM\\Bundle\\AccountBundle\\Entity\\Account’.\”) in \”/var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig\” at line 44. at /var/www/orocrm/vendor/twig/twig/lib/Twig/Template.php:182, Doctrine\\ORM\\Mapping\\MappingException(code: 0): No mapping found for field ‘areaManager’ on class ‘OroCRM\\Bundle\\AccountBundle\\Entity\\Account’. at /var/www/orocrm/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:163)”} []

    The class “Account” is under “src/MatchPint/Bundle/DugoutAccountBundle/Entity/” and its namespace is “MatchPint\Bundle\DugoutAccountBundle\Entity”. Am I doing something wrong?

    I have read the documentation that you have linked, but unfortunately the example shows how to extend a new entity created in the same bundle namespace, it doesn’t show how to extend an existent entity like Account.

    I have even tried to replace “vendor/oro/crm/src/OroCRM/Bundle/AccountBundle/Entity/Account.php” with the implementation I have provided, using a symlink, but it didn’t work. The guide, honestly, is really bad and moreover, since I’m running OroCRM inside a Docker container, even on my machine, which is a MacBook Pro 15″ mid 2015 with 16 GB of RAM, is so slow that clearing the cache takes minutes. And there is no way to debug because this damn Symfony cache.

    Please point me in the right direction because I’m not doing any progress.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.