How can I execute plugin method when order placed

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I've pm'd you, a zip or w/e will be totally fine
11 years ago
M.Ang wrote:
I've pm'd you, a zip or w/e will be totally fine


Grazie mille

Email sent
11 years ago
Just wanted to check you received my email OK and it wasn't languishing in a spam folder somewhere
11 years ago
Hello,
first thing i noticed immediately, the Output build path for the project Nop.Plugin.Misc.PriceGrabber is wrong, it was like this:

..\Presentation\Nop.Web\Plugins\Misc.FavoriteCategories\


whether it should be like this

[code]..\..\Presentation\Nop.Web\Plugins\Misc.FavoriteCategories\[\code]

didn't you notice the Presentation folder being created inside the Plugin folder in the project root? :)


I'm testing the actual functionality, but i think that's the problem, the plugin was never being loaded.
11 years ago
Addendum:

in the FavoriteCategoriesPlugin Contructor, you must specify interfaces for Dependency Injection, like so:


        private readonly FavoriteCategoriesObjectContext _context;
        private readonly IFavoriteCategoriesService _favoriteCategoriesService;
        private readonly IOrderService _orderService;
        private readonly ISettingService _settingService;

        public FavoriteCategoriesPlugin(FavoriteCategoriesObjectContext context, IFavoriteCategoriesService favoriteCategoryService, IOrderService orderService, ISettingService settingService)
        {
            _context = context;
            _favoriteCategoriesService = favoriteCategoryService;
            _orderService = orderService;
            _settingService = settingService;
        }


If you try and request "FavoriteCategoriesService" or "SettingService" instead of the interfaces, AutoFac will fail, since them have not been registered.
11 years ago
Ok, other than these two things, the Consumer is being called and the HandleEvent is being invoked.

Careful now, i briefly tested the HandleEvent and it fails with a NullReferenceException.

I'm saying careful because nop will silently pass on that exception, because of this:


            try
            {
                x.HandleEvent(eventMessage);
            }
            catch (Exception)
            {
                //TODO:Log this some how. We can't reference the ILogger because the interface exists in another assembly. Maybe we can move all interfaces to Nop.Core and all the implemntes to Nop.Services?
            }
11 years ago
M.Ang wrote:
Hello,
first thing i noticed immediately, the Output build path for the project Nop.Plugin.Misc.PriceGrabber is wrong, it was like this:

..\Presentation\Nop.Web\Plugins\Misc.FavoriteCategories\


whether it should be like this

[code]..\..\Presentation\Nop.Web\Plugins\Misc.FavoriteCategories\[\code]

didn't you notice the Presentation folder being created inside the Plugin folder in the project root? :)


I'm testing the actual functionality, but i think that's the problem, the plugin was never being loaded.


Hi,

Thanks for getting back to me

I'm not at my dev machine until tomorrow so can't check what you're saying here. All I do know is that the plugin appeared in the plugins list, it installed OK and created the required table in the Db.
11 years ago
M.Ang wrote:
Addendum:

in the FavoriteCategoriesPlugin Contructor, you must specify interfaces for Dependency Injection, like so:


        private readonly FavoriteCategoriesObjectContext _context;
        private readonly IFavoriteCategoriesService _favoriteCategoriesService;
        private readonly IOrderService _orderService;
        private readonly ISettingService _settingService;

        public FavoriteCategoriesPlugin(FavoriteCategoriesObjectContext context, IFavoriteCategoriesService favoriteCategoryService, IOrderService orderService, ISettingService settingService)
        {
            _context = context;
            _favoriteCategoriesService = favoriteCategoryService;
            _orderService = orderService;
            _settingService = settingService;
        }


If you try and request "FavoriteCategoriesService" or "SettingService" instead of the interfaces, AutoFac will fail, since them have not been registered.


I thought I had done this actually. Again I'll have a look tomorrow when I'm back in the office.
11 years ago
M.Ang wrote:
Ok, other than these two things, the Consumer is being called and the HandleEvent is being invoked.

Careful now, i briefly tested the HandleEvent and it fails with a NullReferenceException.

I'm saying careful because nop will silently pass on that exception, because of this:


            try
            {
                x.HandleEvent(eventMessage);
            }
            catch (Exception)
            {
                //TODO:Log this some how. We can't reference the ILogger because the interface exists in another assembly. Maybe we can move all interfaces to Nop.Core and all the implemntes to Nop.Services?
            }


Does the code in the HandleEvent method run past this line for you?

var plugin = pluginDescriptor.Instance() as FavoriteCategoriesPlugin;
11 years ago
wunpac wrote:

Hi,

Thanks for getting back to me

I'm not at my dev machine until tomorrow so can't check what you're saying here. All I do know is that the plugin appeared in the plugins list, it installed OK and created the required table in the Db.


Ah, i actually thought that was the problem, i placed your plugin folder in the src/Plugins folder and after build the result never actually shows up (due of the wrong output path). Maybe the version you gave to me was an old one?

I'm not by my dev machine either, i'll report back later
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.