Breadcrumb links depending on base or variant product

Hi,

I’m trying to change the way the breadcrumb is constructed when viewing a base product. Right now the last value in the breadcrumb link points to the first variant in the variant list. E.g: cateogry/baseProduct/123456. This is fine for the variant product. But in the case when viewing a base product I want the breadcrumb to show just: category/baseProduct.

What is the prefered and proper way to verify what type of page or product you are currently viewing? I guess I want the breadcrumb builder to be able to make a distinction between a base and variant product page.

I’ve tried a few things in the breadcrumb builder. Like using the SelectedVariant to check if it’s null. Also tried setting a true/false value in the ProductPageViewModelBuilder. But I’m thinking that it somehow should be possible using the PageModel to find out what type of page you are viewing?

Litium version: 7.7.1

1 Like

Not sure if I understand how you have things setup.

But in general, it’s decided by the template used by the product if the URL exists on either the base product level or on the variant level. If it’s the latter, each variant would get its own product page. The base product would not get a page. So if the URL is on the variant, you can’t visit the base product page for the same product.

By default the bread crumb will use the base product name if the URL is on the base product. Consider these examples:
https://demo.litium.com/man/tools/yogamatposition-637865390184803907 (URL on base product)
https://demo.litium.com/woman/tops/court-dress-black_l-637865390184803907 (URL on variant)

The title used is from the expected entity, based on the ProductModel that is either built from the base product or the variant.

Not sure if I understand how you have things setup.

Sorry, neither do I. It was a bad explanation.

We have the possibilty to view a page representing a base product. That page contains a list of all variants. Right now the bread crumb also shows the first variant of the base product when viewing the base product page. I want to cut off that variant from the bread crumb when viewing a base product. That variant in the bread crumb should only show when viewing a variant page.

I’m thinking that I want to be able to determine what kind of page I’m viewing in BuildProductLinkChain which per default takes a ChannelModel , CategoryModel and ProductModel . The cshtml file is using a ProductPageViewModel. Maybe some kind of Id like SystemId (?) from any of the models or something similar could be used to distingush between a base and variant product page in BreadCrumbsViewModelBuilder?

The title used is from the expected entity, based on the ProductModel that is either built from the base product or the variant.

Is it possible to tell if the ProductModel used in BuildProductLinkChain is built from a variant or a base product? I think that’s what I’m looking for.

The ProductModel has a property UseVariantUrl that is set to true if the template setting is that the URL is on the Variant, not sure if that works with how you have it setup with both base product and variant pages for the same product.

There’s also a FieldValueSelectorType property that will be set to BaseProductAndVariant if the model was built from a base product, and VariantAndBaseProduct if built from a variant.

Something like this is what I had in mind. Works in my case. Thank you very much.

No, this didn’t work with my setup. It’s always set to true in every case.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.