OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Associating Entity with Activity using Migration

This topic contains 6 replies, has 2 voices, and was last updated by  andytnumiko 7 years, 10 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
  • #36138

    andytnumiko
    Participant

    Hi,

    I’m trying to associate a custom entity with a custom activity. I’m following the example here https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/ActivityBundle/README.md but when I run the migration I get:

    “[LogicException]
    A new model can be created for custom entity only. Class: [entity]”

    (where [entity] is the entity I’m trying to associate with the activity)

    My migration code is (naming changed for confidentiality):


    namespace...

    class CAEntityBundle implements Migration, ActivityExtensionAwareInterface
    {
    /** @var ActivityExtension */
    protected $activityExtension;

    /**
    * {@inheritdoc}
    */
    public function setActivityExtension(ActivityExtension $activityExtension)
    {
    $this->activityExtension = $activityExtension;
    }

    /**
    * {@inheritdoc}
    */
    public function up(Schema $schema, QueryBag $queries)
    {
    self::addActivityAssociations($schema, $this->activityExtension);
    }

    /**
    * Enables Email activity for User entity
    *
    * @param Schema $schema
    * @param ActivityExtension $activityExtension
    */
    public static function addActivityAssociations(Schema $schema, ActivityExtension $activityExtension)
    {
    $activityExtension->addActivityAssociation($schema, 'ca_activity', 'ca_entity', true);
    }
    }

    I’m not sure what constitutes a “custom entity” given that we created the entity?

    Thanks for you help.
    Andy

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #36139

    andytnumiko
    Participant

    Turns out the error was from a different migration. The –bundles option on oro:migration:load doesn’t seem to have any effect.

    #36140

    andytnumiko
    Participant

    Ok, I can see that it creates the oro_rel_… table.

    But my activity doesn’t show in the actions area when I view the entity. And it doesn’t show up as ticked in the list of activities in the entity config.

    If I add the activity to an Oro entity through the interface (e.g. Tracking Website) it DOES work. Everything seems to work fine in that case.

    Is there any extra config that needs to be done? Do I need to create an entity_config.yml for the target entity? There seems to be some progress if I try that but I can’t get the format correct.

    thanks

    #36141

    andytnumiko
    Participant

    Forgetting the entity_config.yml, if I add this to the Entity class:

    and run oro:entity-config:update –force,

    when I run oro:entity-config:debug “….”

    it looks right:

    And the activity shows ticked on the entity edit page.

    However, when I save an entity it says “Class Oro\Bundle\ActivityListBundle\Entity\ActivityList has no association named …”

    #36142

    andytnumiko
    Participant

    It seems to be fixed with a

    app/console oro:entity-extend:update-schema

    etc.

    although there’s a lot going on so I can’t be 100% sure. All working now though.

    Hopefully I’ll get time to put together a blog post on how to do this – it’s been quite a journey.

    thanks

    #36143

    archy_bold
    Participant

    Hi Andy. Did you ever write the blog post? I’m having trouble doing exactly this myself.

    My issues are explained in better detail here: https://oroinc.com/orocrm/forums/topic/creating-custom-activity-entity

    #36144

    andytnumiko
    Participant

    I’m afraid not, sorry. Not sure what to suggest.

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

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top