need to add tab into product edit page admin side

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 6 años
Now i need to add tab into product edit page. How to display My View data from plugin to new tab of product ?


My code is

public class AdminTabStripCreatedEventConsumer : IConsumer<AdminTabStripCreated>
    {
        private readonly ICompositeViewEngine _viewEngine;

        public void HandleEvent(AdminTabStripCreated eventMessage)
        {
            if (eventMessage.TabStripName != "product-edit")
                return;

            var evc = EngineContext.Current.Resolve<ExtendedProductController>();
            var vendorId = evc.GetCurrentVendorId();
          
            content = ViewRenderer.RenderPartialView("ExtendedProduct/_TabView", Id);
            eventMessage.BlocksToRender.Add(new HtmlString(content));
        }
}


Now i am using nopCommerce 4.0 version. I need to implement this code from plugin. any alternative way to implement ViewRenderer.RenderPartialView  ?
Hace 6 años
Hello,

Look at this https://www.nopcommerce.com/boards/t/43569/how-can-my-plugin-add-a-tab-into-product-or-category-admin-view.aspx#172964
Hace 6 años
I got the my solution from WorldPay plugin



public class AdminTabStripCreatedEventConsumer : IConsumer<PageRenderingEvent>, IConsumer<AdminTabStripCreated>
    {                
        public void HandleEvent(AdminTabStripCreated eventMessage)
        {
            if (eventMessage?.Helper == null)
                return;

            //we need customer details page
            var tabsElementId = "product-edit";
            if (!eventMessage.TabStripName.Equals(tabsElementId))
                return;

            //compose script to create a new tab
            var productEditTabElementId = "tab-productEdit";
            var productEditTab = new HtmlString($@"
                <script type='text/javascript'>
                    $(document).ready(function() {{
                        $(`
                            <li>
                                <a data-tab-name='{productEditTabElementId}' data-toggle='tab' href='#{productEditTabElementId}'>
                                    {_localizationService.GetResource("Plugins.Payments.Worldpay.WorldpayCustomer")}
                                </a>
                            </li>
                        `).appendTo('#{tabsElementId} .nav-tabs:first');
                        $(`
                            <div class='tab-pane' id='{productEditTabElementId}'>
                                {
                                    //
                                    eventMessage.Helper.Partial("~/Plugins/Widgets.ProductReviews/Views/_TabEditProduct.cshtml", 0).RenderHtmlContent()
                                        .Replace("</script>", "<\\/script>") //we need escape a closing script tag to prevent terminating the script block early
                                }
                            </div>
                        `).appendTo('#{tabsElementId} .tab-content:first');
                    }});
                </script>");

            //add this tab as a block to render on the customer details page
            eventMessage.BlocksToRender.Add(ProductEditTab);
        }
    }
}
Hace 6 años
That's good #sangitshah
Hace 6 años
Good. Thanks for sharing Sangeet
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.