+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Finding product type

Finding product type

3 posts, 0 answered
  1. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    14 Dec 2011
    Link to this post
    Hi,

    In my custom product widgets that I'm building I need to apply a different template depending on the product type of the product. Once I have identified the product, how can I find out what the product type is?

    I need to be able to do something like this;
    switch(theProductType)
    {
    case "Fruit":
    ...some code to display the fruit template
    case "Vegetable":
    ...some code to display the veg template
    ...etc.
    }

    thanks
    Pete
  2. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    14 Dec 2011
    Link to this post
    Just to add, I can use .GetType on the product object to get something like "sf_ec_prdct_fruit" (sf_ec_prdct_generalproduct for standard products), is this the best I'm going to get?
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    08 Dec 2016
    16 Dec 2011
    Link to this post
    Hi Nick,

    Since product types are dynamic types, you'll need to operate with the type names like the one you mentioned. However, this should not be a problem when constructing your switch statement, you just have to adjust the matching patterns to match the product types naming.

    Best wishes,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered