Forums OroPlatform OroPlatform – Programming Questions How to add attachements to custom entity

This topic contains 3 replies, has 2 voices, and was last updated by  Yurii Muratov 2 years, 3 months ago.

  • Creator
  • #28483

    Neal Vanmeert

    Hi, I created a custom bundle with a custom entity.

    In my migrations I added AttachmentExtensionAwareInterface

    * {@inheritdoc}
    public function up(Schema $schema, QueryBag $queries)
    $table = $schema->createTable('emuse_businesscard');
    $table->addColumn('id', 'integer', ['autoincrement' => true]);
    $table->addColumn('owner_id', 'integer', ['notnull' => false]);
    $table->addColumn('createdAt', 'datetime', []);
    $table->addColumn('updatedAt', 'datetime', ['notnull' => false]);
    $table->addIndex(['owner_id'], 'IDX_2F32390A7E3C61F9', []);
    self::addUploadToBusinessCard($schema, $this->attachmentExtension);

    * @param Schema $schema
    * @param AttachmentExtension $attachmentExtension
    public static function addUploadToBusinessCard(Schema $schema, AttachmentExtension $attachmentExtension)

    But when I run my migrations I get an error:

    php app/console oro:migration:load --dry-run --show-queries

    An extend field "businesscard_upload" cannot be added to non extend entity "eMuse\Bundle\BusinessCardBundle\Entity\BusinessCardEntity".

    How can I make my entity extendable, or what is the best way to add an attachement ?

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

    Yurii Muratov

    Hi, @neal_vanmeert.

    To make your entity extenable, your entity should extends from empty class eMuse\Bundle\BusinessCardBundle\Model\ExtendBusinessCardEntity.
    And another thing, your entity should be configurable (should have @Config annotation).

    For example, please look how it was done for Account entity
    Here, at line 28 we have Config annotation and at line 60 we have extends from empty OroCRM\Bundle\AccountBundle\Model\ExtendAccount class.


    Neal Vanmeert

    Hi, This indeed helped, I don’t really understand how an extend of an empty class makes this work. Is there info to be found ?

    We are interested in OroCRM and creating modules for it, but we are lacking information to really create quality code.


    Yurii Muratov

    Hi, @neal_vanmeert.
    We have some documentation about extend entities here

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

You must be logged in to reply to this topic.