Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

I can't get the right breadcrumb.

Vote:
 
I have a .net 4.6.1 project 

with cms and commerce

in cms I have the page structure.

in commerce I have the catalog

tree view example catalog commerce:
home -> category1.1 -> category1.2 -> product1
home -> category1.1 -> category1.3 -> product1

When I access product1 in commerce in belongs to.

main category
home -> category1.1 -> viewall

Additional Categories
home -> category1.1 -> category1.3
home -> category1.1 -> category1.2

When I enter the product page I always get the full breadcrumb because it is the main one.

but the user was able to browse
home -> category1.1 -> category1.3

How can I show the correct breadcrumb?
#284004
Jul 20, 2022 20:34
Vote:
 

Hi can you look at here if this solves your issues? https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/common-web-page-component-tutorials/how-to-create-a-breadcrumb-in-episerver/

If not then let me know I can help you with the custom one.

#284045
Jul 21, 2022 10:30
Daniel - Aug 22, 2022 7:13
Your proposal doesn't work for me because in that case it always takes the main category as epi and not the navigation category.
Vote:
 

Daniel,

Im not sure I fully understand your question, can you elaborate on: "How can I show the correct breadcrumb?"

From your example your product1 exists in the categories category1.1, category1.2 and category1.3.

What breadcrumb end result are you trying to achieve?

#284148
Jul 21, 2022 15:47
Daniel - Aug 22, 2022 7:19
in the bkoffice I have product1 in:

- main category:
home -> category1.1 -> category1.1.1 -> product1

-additional.
home -> category1.1 -> category1.1.2 -> product1
home -> category1.1 -> category1.1.3 -> product1

If the user browses
home -> category1.1 -> category1.1.2 -> product1

the breadcrumb should be this
home -> category1.1 -> category1.1.2 -> product1
however, I get this wrong breadcrumb:
home -> category1.1 -> category1.1.1 -> product1

the only thing that occurs to me is that the solution is to save in session?
because if I consult in bkend it will always give me the main one. and that is wrong in terms of navigation.

Surjit Bharath - Aug 22, 2022 7:24
You could potentially but there might be another way.

What if you took the URL of product1 when the customer requests it and then use that to build your breadcrumb?

So https://yoursite/category1.1/category1.1.2/product <-- your breadcrumb is in the url
Daniel - Aug 25, 2022 14:07
no, I do not have it.
I discarded that path of solution.

currently the list of products goes with this url.
https://yoursite/category1.1/category1.1.2/

but when I access the product it looks like this:
https://yoursite/product

therefore I cannot get the breadcrumb from the url since the query is from bakend and it always returns the configured main one and not the navigation one.

for that reason I was thinking of session.
Vote:
 

currently the list of products goes with this url.
https://yoursite/category1.1/category1.1.2/

but when I access the product it looks like this:
https://yoursite/product

therefore I cannot get the breadcrumb from the url since the query is from bakend and it always returns the configured main one and not the navigation one.

What would be the solution so that the breadcrumb is correct from the product list navigation?

without skipping the default breadcrumb configured in the
episerver/Commerce/Catalog
#286174
Aug 26, 2022 8:26
Vote:
 
#286175
Aug 26, 2022 9:29
Daniel - Aug 30, 2022 7:11
is obsolete
Vote:
 

That's a clever way of doing it!

@Quan's answer is a good one

#286298
Aug 29, 2022 8:11
Vote:
 
I'm sure it's a good solution.
I have tried to do it without success.
- in the catalog when I enter a product
breadcrumb never matches "Additional Categories"
- and when I browse the web the same thing happens.
breadcrumbs never contain Additional Categories

On the other hand I have a web component called Breadcrumbs

public ActionResult Index(IContent currentContent)
        {
            var model = new BreadcrumbsViewModel
            {
                Breadcrumbs = LoadBreadcrumbs(currentContent).ToArray(),
            };
            return PartialView(model);
        }

private IEnumerable<BreadcrumbItem> LoadBreadcrumbs(IContent currentContent)
        {

            var breadcrumbs = currentContent is PageData page
                ? LoadPageBreadcrumbs(page)
                : _breadcrumbsService.LoadCommerceBreadcrumbs(currentContent);
            return breadcrumbs;
        }

        private IEnumerable<BreadcrumbItem> LoadPageBreadcrumbs(PageData pageData)
        {
            var breadcrumbItems = Enumerable.Empty<BreadcrumbItem>();
            if (ShowBreadcrumbsForPage(pageData))
            {
                var breadcrumbsContent =
                    new[] { _contentLoader.GetStartPage(_contentVersionRepository) }
                    .Concat(GetAncestors(pageData).TakeWhile(x => !(x is StartPage)).Reverse())
                    .Concat(new[] { pageData })
                    .Select(x => new NamedLink(x.Name, Url.ContentUrl(x.ContentLink)));
                var tempLeaf = TempData.GetBreadcrumbLeaf();
                if (tempLeaf != null)
                {
                    breadcrumbsContent = breadcrumbsContent.Concat(new[] { tempLeaf });
                }
                breadcrumbItems = _breadcrumbsService.LoadBreadcrumbItems(breadcrumbsContent);
            }

            return breadcrumbItems;
        }


but it always returns the breadcumb set as main for the article
#286353
Aug 30, 2022 7:08
Vote:
 

I think maybe you were along the right lines with storing information in the session in that case.

Maybe you could have a variable that stores the last visited category page? Then when you navigate to the product page, you should double check that the stored category does indeed contain the product (so doesn't matter if its primary or additional) then navigate back up the category tree from the stored category.

#286470
Sep 01, 2022 14:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.