ssossossossosso

Forums

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

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 3 years, 2 months ago.

  • Creator
    Topic
  • #22137

    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
  • #22138

    Dima Soroka
    Keymaster

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

    #22139

    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.

    #22140

    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();

    #22141

    I’ve wrote this :

    The error message:

    I don’t know how to make. Thanks.

    #22142

    I’ve changed my code:

    And when I test this = fail.

    Help please ^^ thanks.

    #22143

    Error message :

    #22144

    No ideas?
    Thanks.

    #22145

    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.

    #22146

    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.

    #22147

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

    #22148

    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)

You must be logged in to reply to this topic.