Store wise route from custom plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 8 años
Hello,

I have developed on custom plugin in which I have override one route say catalog/searchtermautocomplete. Now I am having multi-store as nopCommerce provide multi-store functionality.

Now, I want to load this overridden route for my First store and default route which is for Catalog Controller and SearchTermAutoComplete method for Second store.

Is there any possibility to achieve this? How?

Thanks.
Hace 8 años
divyang16 wrote:
Hello,

I have developed on custom plugin in which I have override one route say catalog/searchtermautocomplete. Now I am having multi-store as nopCommerce provide multi-store functionality.

Now, I want to load this overridden route for my First store and default route which is for Catalog Controller and SearchTermAutoComplete method for Second store.

Is there any possibility to achieve this? How?

Thanks.


Hi,

I think there is no such thing as "route per store".

One possible solution is to create one route pointing to your action. Then in this action use the logic in which store you are and redirect to the corresponding action.

Your logic can be structured this way:
Create your own route, e.g. /myPluginCustomRoute that will point to MyPlugin/MyCustomRouteAction. Inside this method the logic will be as follows:
if(FirstStore) {
    return RedirectToAction("MyCustomAction", "MyPlugin");
}
else {
    return RedirectToAction("SearchTermAutoComplete", "Catalog");
}


I hope this helped!

Regards,
Deni
Hace 7 años
Nop-Templates.com wrote:
Hello,

I have developed on custom plugin in which I have override one route say catalog/searchtermautocomplete. Now I am having multi-store as nopCommerce provide multi-store functionality.

Now, I want to load this overridden route for my First store and default route which is for Catalog Controller and SearchTermAutoComplete method for Second store.

Is there any possibility to achieve this? How?

Thanks.

Hi,

I think there is no such thing as "route per store".

One possible solution is to create one route pointing to your action. Then in this action use the logic in which store you are and redirect to the corresponding action.

Your logic can be structured this way:
Create your own route, e.g. /myPluginCustomRoute that will point to MyPlugin/MyCustomRouteAction. Inside this method the logic will be as follows:
if(FirstStore) {
    return RedirectToAction("MyCustomAction", "MyPlugin");
}
else {
    return RedirectToAction("SearchTermAutoComplete", "Catalog");
}


I hope this helped!

Regards,
Deni


We have used custom model. If we redirect to base method(SearchTermAutoComplete in catalog controller) model is empty. What we can do in that case?
Hace 7 años
As I try your solution it's did not work with any store.

if(FirstStore) {
    return RedirectToAction("MyCustomAction", "MyPlugin");
}
else {
    return RedirectToAction("SearchTermAutoComplete", "Catalog");
}


It's stop with all store
Hace 7 años
As I try your solution it's did not work with any store.

if(FirstStore) {
    return RedirectToAction("MyCustomAction", "MyPlugin");
}
else {
    return RedirectToAction("SearchTermAutoComplete", "Catalog");
}


It's stop with all store

My code like:

foreach (var item in allStore)
            {
                var myPluginSettings = _settingService.LoadSetting<myPluginSettings >(item.Id);
                if (_pluginFinder.GetPluginDescriptorBySystemName("my.Plugin.custom.Search") != null)
                {
                    
                        if (myPluginSettings.EnableMySearch)
                        {
                            routes.MapLocalizedRoute("myPlugin.ProductSearch", "search/",
                                new { controller = "CustomSearch", action = "Search" },
                                new[] { "my.Plugin.custom.Search.Controllers" });

                            //autocomplete
                            routes.MapLocalizedRoute("myPlugin.ProductSearchAutoComplete",
                                    "catalog/searchtermautocomplete",
                                    new { controller = "CustomSearch", action = "SearchTermAutoComplete" },
                                    new[] { "my.Plugin.custom.Search.Controllers" });

                            
                        }
                    


                }
            }
Hace 7 años
Please reply :(
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.