Exposing and Handling Custom Events - Plugin 3.9

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 6 ans
I have multiple plugins developed.
I need to trigger events from one plugin and they need to be recognized by other plugins.

I found a thread in this forum where the fellow answered his own questions, somewhat, where he built an "Event" plugin that contained his events. I am guessing the Publish methods.

I tried to formulate a similar plan, and the event fires and my publish event runs in my "Event" plugin.
However, the other plugins don't get notified that the event has been fired.

In the main plugin, I call the eventPublisher.Publish(args)
This then routes to the Nop.Services.Events.EventPublisher.Publish<T>(T eventMessage)

I make it here fine.
However, the first line of code is

var subscriptions = _subscriptionService.GetSubscriptions<T>();

The subscriptions are returning empty.

When I follow it, it calls Nop.Services.Events.SubscriptionService.GetSubscriptions<T>

This then calls  EngineContext.Current.ResolveAll<IConsumer<T>>

Then Nop.Core.Infrastructure.DependencyManagement.ContainerManager.ResolveAll<T> is called.

Here the scope and key are always null and empty (even when EntityUpdated<T> is called when updating a product)



It seems like the Consumers in the secondary plugins aren't getting registered or the EngineContext can't find it.

Thanks in advance for any help.
Il y a 6 ans
Ok. So I bang my head on the keyboard, then step through and then write the post.
Then I go through again and notice a critical error.

Apparently, when I hit the Ctrl + . in Visual Studio, I selected to create a class instead of add the using statement for the "Event" plugin.

I noticed the last step through that it was looking for IConsumer<Wrong NameSpace.MyEvent>.

I like when it is a simple fix of an error, I just don't like the time it takes to find it :)


It works well now!!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.