ssossossossosso

Forums

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

Forums Forums OroCommerce Extend core entities

This topic contains 3 replies, has 3 voices, and was last updated by  jderdziak 7 months, 3 weeks ago.

  • Creator
    Topic
  • #32117

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

    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

    #32119

    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!

    #32120

    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)

You must be logged in to reply to this topic.