I want to show user selected store and category on product detail page like this Store Name Category Name > Product Name. How can I get user selected store and category from Product detail page. I use nopCommerce 3.0.
2 回答
For the store name, you can use the store context object:
_storeContext.CurrentStore
But for the category, are you aware that a product can belong to multiple categories in nopCommerce? This is stored in the ProductCategories
collection of the Product
entity.
I have a problem with
_storeContext.CurrentStore
This everytime gives me wrong store information and the reason is described here
plugin-get-current-storeid-multi-store
So i have used the below code which i got from looking NivoSlider Plugin .
var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
_storeService
is type of IStoreService
_workContext
is type of IWorkContext
Use it via dependency injection from constructor.