Try our conversational search powered by Generative AI!

Finding Variant information


How to find Variant path which displayed in commerece catalog /product/variant.

Jul 22, 2019 13:33

Log into the Commerce catalog. Then, navigate to the variant and click the Belongs to tab to see its path.

Jul 22, 2019 18:25
Janakiram - Jul 23, 2019 5:51
Hi Bob,
Thanks for your quick reply, but
I need to get that in code.
The path has to be shown in elsewhere in my project. I am able get the variant but unable to find path string.
Please help me if there is way to find it.
Paul Middleton - Jul 24, 2019 17:27
Hi - You need to read up on how the RelationRepository works - details here :

It is unclear what you are trying to do, but i assume you want to get the variant url

From the code you can use ReferenceConverter to get the content link

From the content link you can use UrlResolver.GetUrl to get the url of the content. In this case, the variant

Jul 23, 2019 8:34
Janakiram - Jul 23, 2019 10:51
Hi Quan,
As in Bob Bolt suggestion in image we can see 'Primary Category'' , under that there is an item called "Mens Jacket" by the side of that we can see a hierarchical text. We need to get that string for a variant to show exactly how that is shown in the above image. We don't need the url. We are able to get the url as you suggested. If there is any way , please let me know. I really appreciate your reply.

We have created some EntryContentExtensions that will help you to retrieve the PrimaryCategory

public static NodeContent GetCategory(this EntryContentBase entryContent, IContentLoader contentLoader = null)
    return GetCategory<NodeContent>(entryContent, contentLoader);

Here is the method GetCategory<T>() definitions

public static T GetCategory<T>(this EntryContentBase entryContent, IContentLoader contentLoader = null)
    where T : NodeContent
    if (entryContent == null)
        return null;

    if (contentLoader == null)
        contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

    var nodeContent = contentLoader
        .FirstOrDefault(x => x is T);

    return nodeContent as T;

Let me know if it helps you.


Jul 29, 2019 16:47

What you mentioned in the comment sounds like bread crumb. If that is the case, you can do like this (Recipe 1.9) 

Jul 29, 2019 17:27
* 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.