ssossossosso

Forums

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

This topic contains 3 replies, has 2 voices, and was last updated by Andrey Mishchenko Andrey Mishchenko 2 years, 1 month ago.

  • Creator
    Topic
  • #9872

    cardiac
    Participant

    Hi all,

    I currently try to send an email through OroPlatform and I want the email to get logged.
    I have a new entity and want to send an email onPersist. But I want the email to get displayed in entity like user emails do.

    Can you give me a hint or an example how to do it the best way?

    First I tried a service with an doctrine listener but I needed config and entity manager and so there was a dependency problem. Now I send the mail with a job which gets trigger by the event listener.

    How do you do it?

    Best regards

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

    Hello, cardiac!

    Take a look at https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/ActivityBundle/README.md. `How to enable activity association using migrations` chapter describes how to add email activity association to an entity. In your case it will be something like

    To assign specific email to specific entity you should use Oro\Bundle\EmailBundle\Entity\Manager\EmailActivityManager::addAssociation() method.

    To automatically render related activities you should extend your entitie’s view template from OroUIBundle:actions:view.html.twig.

    Best regards

    P.S. Could you also provide more information about dependency problem you get while using doctrine listener?

    #9884

    cardiac
    Participant

    First: Thank you for you help! I will try you solution later on.

    P.S. Could you also provide more information about dependency problem you get while using doctrine listener?

    Sure.

    I created a LeadMailProcessor which depends on:
    – @doctrine.orm.entity_manager
    – @oro_config.global
    – @oro_email.email_renderer
    – @oro_email.direct_mailer

    If you try to inject this service to the event listener, you will get an error with the injected services entity manager and config manager. (Something like dependency loop – do not know the exact error message).

    I’m currently using a job to avoid this problem.

    #9885

    Thank you for providing additional information.

    Try to inject @doctrine instead of @doctrine.orm.entity_manager into your service and use getManager method to retrieve an instance of EntityManager inside the service.

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

You must be logged in to reply to this topic.