Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Emil Schoelzer Schnohr 23 posts 143 karma points
    Jun 05, 2020 @ 09:11
    Emil Schoelzer Schnohr
    0

    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!

  • nibbe 9 posts 99 karma points
    Jul 26, 2020 @ 10:00
    nibbe
    0

    I'm experiencing the same problem that catalogContext.CurrentCategories is an empty list. Have you found a solution for this Emil?

  • Emil Schoelzer Schnohr 23 posts 143 karma points
    Aug 28, 2020 @ 12:47
    Emil Schoelzer Schnohr
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft