OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Entity extend via migration doesn't work properly

This topic contains 4 replies, has 2 voices, and was last updated by  Takushi 5 years, 2 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
  • #37963

    Takushi
    Participant

    Hello,

    I tried to add the field head_office into the entity Organization with this migration:

    When i perform the command php app/console cache:clear -vvv, i get this error:
    Property Oro\Bundle\OrganizationBundle\Entity\Organization::$head_office does not exist

    And the file in the cache doesn’t implement new value:

    I have another entity that extends Oro\Bundle\OrganizationBundle\Model\ExtendOrganization and having some relation fields.

    I am on Oro V2.6.

    Thank.

    • This topic was modified 5 years, 2 months ago by  Takushi. Reason: Oro version
Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #37966

    Yevhen Shyshkin
    Participant

    Hello Takushi.

    To create new extended field you have to run you migration. Recommended way – execute oro:platform:update command. https://oroinc.com/orocrm/doc/2.6/dev-guide/cookbook/how-to-upgrade-to-new-version

    As for another entity extended from Oro\Bundle\OrganizationBundle\Model\ExtendOrganization – it’s not recommended as each extended entity has to have it’s own extended classes. Otherwise application simply will not be able to create correct class aliases for extented entities.

    #37969

    Takushi
    Participant

    Thanks for your response.

    My problem is solved by removing the ExtendOrganization on other entity.

    What is the recommended way to make this entity same as Organization (with the same properties, relation, etc..) ?
    Do i have to duplicate entire Organization entity with his migrations ?

    Thank.

    #37983

    Yevhen Shyshkin
    Participant

    The easiest solution is indeed just make a copy of the original organization entity, call it e.g. AdvancedOrganization and then create separate extended model class called ExtendAdvancedOrganization – this way you will have your own independent organization and independent extended entity for it.

    Pay attention that in this case new organization entity will not inherit built in organization related features like ACL, ownership etc.

    But before that you may stop for a moment and think a little about two absolutely identical entities in your application (which looks like violation of SOLID). Maybe you can add extended boolean flag (e.g. isAdvanced) to the standard Organization entity and distinguish them in this way? Or set some organization as a special organization in the System Configuration and then use this reference to identify it? Or your custom organization logic can be emulated using standard Business Units?

    #37984

    Takushi
    Participant

    Thank you Yevhen Shyshkin !

    I mark the topic as resolved.

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

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

Back to top