ssossossosso

Forums

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

This topic contains 6 replies, has 2 voices, and was last updated by  andytnumiko 1 year, 4 months ago.

  • Creator
    Topic
  • #14873

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

    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.

    #14993

    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

    #14995

    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 …”

    #15000

    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

    #17763

    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://www.orocrm.com/forums/topic/creating-custom-activity-entity

    #17788

    andytnumiko
    Participant

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

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

You must be logged in to reply to this topic.