OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Extend core entities

This topic contains 3 replies, has 3 voices, and was last updated by  jderdziak 6 years, 11 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
  • #31642

    tjurczak
    Participant

    I would like to extend customer entity to add new field “vat”. This field should be editable in backend and visible on grids. I decited to use EntityExtendBundle. I wrote migration script and new field has been appeared on backend. Great, but now I would like to use this field in businness logic in code $customer->getVat(). You warn on documentation:

    It is not recommended to rely on the existence of dynamic fields in your business logic since they can be removed by administrative users.

    What should i do? Mark dynamic field as “is system” (to prevent to delete entity) and create some mock class for intelisense in IDE (how?), or maybe i should use different method to add new fields like overriding entity objects (standard symfony).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #31643

    msulima
    Moderator

    Hi,

    Yes, you right. You should mark that field as system, that will prevent deletion of that field from interface.

    In migration please use

    Constant is available in https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/EntityExtendBundle/EntityConfig/ExtendScope.php#L54


    #31644

    tjurczak
    Participant

    I have another problem which is related to extended fields. I want to use extended field (vat) in registration form. If I add new field in form (in this example changed class in vendor, vendor/oro/customer-portal/src/Oro/Bundle/CustomerBundle/Form/Type/FrontendCustomerUserRegistrationType.php), bellow exception will be raised durring generation form:

    Neither the property “vat” nor one of the methods “getVat()”, “vat()”, “isVat()”, “hasVat()”, “__get()” exist and have public access in class “Oro\Bundle\CustomerBundle\Entity\CustomerUser”.

    Object form model is vendor/oro/customer-portal/src/Oro/Bundle/CustomerBundle/Entity/CustomerUser.php which know anything about field vat.

    How to add new field in customer registration form? Is it possible if we use extended fields?

    Thanks for help!

    #31645

    jderdziak
    Participant

    Extending CustomerUser is not possible at this moment. It will be corrected in one of the future release. Workaround for now would be to create your own entity, and make a relation to CustomerUser.

    You can see example how can it be done in TaxBundle (see CustomerTaxCode and CustomerFormViewListener).

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

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top