OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Add custom Field into OroCRM Entity?

This topic contains 11 replies, has 4 voices, and was last updated by  hemham914 9 years, 6 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #24757

    How I can add a custom field in OroCRMAccountBundle:Account ?
    I want add a field into my personal Bundle (I don’t want modify the OroCRM Bundle, but extends the Entity into my Bundle).

Viewing 11 replies - 1 through 11 (of 11 total)
  • Author
    Replies
  • #24758

    Dima Soroka
    Keymaster

    You can add your fields as extended fields. Please take a look how it is done in Account Bundle.

    #24759

    Yes I’ve read the documentation and I’ve made the migration (new field into the database) but how I can work with this new field?

    I’ve added two fields into orocrm_account but how I can work with them (with getRepository etc) ?

    Thanks.

    #24760

    Vova Soroka
    Participant

    You can use extended field as regular fields. For instance if you have added ‘test’ field in Account entity, you can do something like this:
    $account = $doctrine->getRepository('OroCRMAccountBundle:Account')->find($accountId);
    $account->getTest();

    #24761

    I’ve wrote this :

    The error message:

    I don’t know how to make. Thanks.

    #24762

    I’ve changed my code:

    And when I test this = fail.

    Help please ^^ thanks.

    #24763

    Error message :

    #24764

    No ideas?
    Thanks.

    #24765

    Vova Soroka
    Participant

    Unfortunately you cannot extend your entity class from Account entity. But if you need to add some additional fields to Account entity just add them in a migration for your bundle, for instance:

    Next, to update the database run oro:migration:load command:

    Also you need to add translations for new fields in Resources/translations/messages.en.yml. In this case:

    After this new fields will be displayed on account view and edit pages automatically.

    #24766

    Dima Soroka
    Keymaster

    @ruizalexandre can you please describe your use case with more details as we would like to understand better your needs. Alternative solution to custom field could be one to one relation.

    #24767

    I’ll try the Vova Soroka’s method, thanks you.

    #24768

    hemham914
    Participant

    I’ve attempted to implement this process in my application like so:

    It seems to work fine when i run oro:migration:load --force --show-queries, however when I update the schema with the oro:entity-extend:update-schema command, I get the following error:

    Any ideas?


    ~Coding my life away~

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

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top