Try our conversational search powered by Generative AI!

Determine if catalogentry is a product or variant by code

Vote:
 

Hi,

What's the best way to determine if an entrycode belongs to a product or variant? 
I have a renderer that has different behaviour for variants and products. 
Using only code as a parameter, is it possible to find out if that code belongs to a product, variant or even perhaps a bundle?


Thanks in advance

#206902
Edited, Sep 03, 2019 15:28
Vote:
 

You can use ReferenceConverter to get the ContentReference from the code, then use the IContentLoader to load the EntryContentBase. From that you can check if the content is a ProductContent, or a VariationContent, or a BundleContent. 

Or you can use this https://github.com/vimvq1987/CatalogContentTypeResolver 

#206907
Sep 03, 2019 15:57
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.