But it returns null. Also, if I try catalogContext.CurrentCategories, it returns an empty list. It's the same problem whether I'm in a SurfaceController or a RenderMvcController, if that's to any help.
It's also worth noting that catalogContext.CurrentCatalog returns the current catalog just as it's supposed to, so I can't be far off.
I don't know if it was a bug or just lack of documentation. Since posting this I have upgraded a couple of times, and today I'm running v 9.2 and everything is working great. The CatalogContex lags CurrentCategory if your url syntax is wrong. In Ucommerce 9.2 I can get UrlService (using Ucommerce.Search.Slugs.IUrlService) to generate the right kind of url, and then I can correctly get CurrentCategory, CurrentCategories and CurrentProduct.
Ucommerce 9: catalogContext.CurrentCategory returns null
I am trying to upgrade an unfinished website from ucommerce 8 to the latest ucommerce 9, but I have trouble getting the category page to work.
In ucommerce 8 I could use Category currentCategory = SiteContext.Current.CatalogContext.CurrentCategory; to get the current category.
Now I have followed the documentation and changed that to:
ICatalogContext catalogContext = ObjectFactory.Instance.Resolve(); Category currentCategory = catalogContext.CurrentCategory;
But it returns null. Also, if I try catalogContext.CurrentCategories, it returns an empty list. It's the same problem whether I'm in a SurfaceController or a RenderMvcController, if that's to any help.
It's also worth noting that catalogContext.CurrentCatalog returns the current catalog just as it's supposed to, so I can't be far off.
Thanks for any help!
I'm experiencing the same problem that catalogContext.CurrentCategories is an empty list. Have you found a solution for this Emil?
I don't know if it was a bug or just lack of documentation. Since posting this I have upgraded a couple of times, and today I'm running v 9.2 and everything is working great. The CatalogContex lags CurrentCategory if your url syntax is wrong. In Ucommerce 9.2 I can get UrlService (using Ucommerce.Search.Slugs.IUrlService) to generate the right kind of url, and then I can correctly get CurrentCategory, CurrentCategories and CurrentProduct.
Using the updated 9.2 docs helped me a lot: https://docs.ucommerce.net/ucommerce/v9.2/getting-started/catalog-foundation/Catalog-Context.html
is working on a reply...