How to add custom sections to Admin product edit page?

11 месяцев назад
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 месяцев назад
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 месяцев назад
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.
10 месяцев назад
aglasencnik wrote:
Any concrete code example?


Look at our Avalara plugin. There is no separate section but some custom inputs on the product page.
10 месяцев назад
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))
10 месяцев назад
Simple question - do you have the widget enabled in Admin ?
See https://yourdomain.com/Admin/Widget/List
10 месяцев назад
Yeah i have noticed that.... But how do I also enabke it if I want to hide the plugin from the widget list?
10 месяцев назад
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);
            }
10 месяцев назад
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.