How to add custom sections to Admin product edit page?

11 months ago
Hi, I am wondering how to add a custom section to an admin product edit page for example (I would also later make it for category edit)? I want to make another "card" or "section", where new inputs would be. Also, how would I capture the save product (or later category), so I would update it and insert a value in my custom table via my db service?
I know there is already a tutorial on this topic but it is quite dated and also it includes more information than necessery. I am using version: 4.60.3
Thanks
11 months ago
Create a Widget that attaches to an Admin Widget Zone
i.e. AdminWidgetZones.ProductDetailsBlock

The widget loads a View that is similar to a cut down vesion of for example

src\Presentation\Nop.Web\Areas\Admin\Views\Product\_CreateOrUpdate.cshtml
11 months ago
I tried that , but I didn't get any results. It didn't show anything. Any concrete code example? And is that widget zone the correct one for adding a item to the edit page inputs a new section? I used that one, and I didn't get anything.
11 months ago
aglasencnik wrote:
Any concrete code example?


Look at our Avalara plugin. There is no separate section but some custom inputs on the product page.
11 months ago
I don't see the inputs, nor do I see my custom code, when I replicate the Avalara approach (but make it simpler (I don't include model building yet))
11 months ago
Simple question - do you have the widget enabled in Admin ?
See https://yourdomain.com/Admin/Widget/List
11 months ago
Yeah i have noticed that.... But how do I also enabke it if I want to hide the plugin from the widget list?
11 months ago
There is a setting in All Settings WidgetSettings.ActiveWidgetSystemNames
So you can add the widget name to the list and if you have the property not to display it should not appear in the list but still be active
Typically you would add the name to the list as part of the install
That Alvera plugin does that
See
            if (!_widgetSettings.ActiveWidgetSystemNames.Contains(AvalaraTaxDefaults.SystemName))
            {
                _widgetSettings.ActiveWidgetSystemNames.Add(AvalaraTaxDefaults.SystemName);
                await _settingService.SaveSettingAsync(_widgetSettings);
            }
11 months ago
Ok, that works now and the section is showed like I want it to be. But there is another problem. When I save the product I want to capture the event, and I need to do some stuff (insert data in my custom table) and I need the custom model, I have in my view. How do I pass the custom model? And where should I capture the event. I was thinking about a EventConsumer, but I can't get the custom model through.