The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
Out of the box, Sitefinity Ecommerce V5 does not have an interface for relating products to each other. This feature is currently in design, but until it is released, I would like to show you how you can create related products using the API and creating a custom view based on products tags.
In Sitefinity Ecommerce, you have the ability to add tags (taxonomies) to products (EX: software, on sale or women's clothing). Sitefinity supports simple tags, categories, facet, and network taxonomies. These advanced taxonomies allow powerful relationships to be represented in Sitefinity. By creating a custom view (using the default view as a template), you can select products which have a the same tag of the main product and show related products under the main product details. Below is the code for the ProductDetailViewCustom.ascx.cs. This should help to give you a better understanding of how to select products based on a tag.
To begin, add 3 separate products into the Sitefinity backend and add the tag “example” to all 3 products. Edit the page which has the product list control on it and click on the edit properties of the product list control. Next, click on the “Advanced” button at the bottom of the control property window, then click on the button “ControlDefinition”. In the ControlDefinition, scroll down to the bottom and click on “Views”. In the views window, you will see 4 different views, select the ProductFrontendDetails which will bring you to the properties for the front end (public facing) views.
In the view window, scroll down to the bottom until you find TemplatePath, this is where you want to add the location of your view/template. In my example, I am using “~/Widgets/Views/RelatedProductsRadRotator/ProductDetailViewCustom.ascx” as my path. Click on the “Save” button at the bottom then publish the page and your are done.
In my example below, I am using the RadRotator for listing my Related Products, however I am also including another example of using the RadListControl. Both views can be used but not at the same time. Only 1 view can be included in the project as both examples have the same class name.
Go to https://gist.github.com/3007808 to download this example using the RadRotator showing related products.
Go to https://gist.github.com/3007820 to download this example using the RadList control showing related products.
NOTE: This template can be outdated. Please use the latest product details template included in Sitefinity version that you use and just add the RelatedProducts section to it.
Credit goes to Boyan Barnev for writing this code. (Thank you B!)
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.