Breadcrumb catalog pagination

We are working with a Treepl template and the products on the site belong in multiple catalogs. However, when you click on a product to go to it’s detail page, the breadcrumbs don’t display the correct catalog from which you came.

For example, if you click on a product in “catalog A” the breadcrumbs on the product detail page may show “Home / catalog B or C / Product” even though you linked from “A”. Is there a way to have the proper catalog show in the breadcrumbs based on which catalog you clicked the to the product detail page?

I’ve tried going into the products individually and rearranging the catalogs in the Catalogs tabs, but it does not hold.

I think you would need to check on the url the user came from by using the {{ request }} liquid object. ({{ request.request_data.referrer }}. You then would need to check with a liquid conditional statement and display the corresponding catalog in the breadcrump (with the correct referrer).
But maybey someone else has a less complicated idea … :slight_smile:

I think the overall issue is that the products URL ({{this.url}}) is actually just the first URL in the list of possible multiple URLs (when a module is configured for multiple parents).

I think management of multiple URLs is coming soon but for now you may need to implement a workaround.

The method @TimL suggests would work in general, but you’d need extra checks for if the product detail is resolved from a direct source that is not a catalog.

This is how I’m handling it so far:

  1. In your Catalog layout, create a Liquid variable so we can easily check when we are inside a Catalog:
{% assign isInCatalog = true %}
  1. Then, in your Product list layout, change where you currently have {{this.url}} to:
{% if isInCatalog == true %}{{request.request_url.path}}/{{product.UrlSlug}}{% else %}{% if product.CanonicalLink != '' %}{{product.CanonicalLink}}{% else %}{{product.url}}{% endif %}{% endif %}

Basically, this will construct the true catalog URL for the product IF being listed within a catalog. Otherwise it’ll try to use the canonical URL if set, else it’ll fallback to the default product URL.

Hopefully, doing this will automatically fix your breadcrumbs too, but it depends how they are being generated as well.