Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Featured products on home page (0.82)


Go to End


2 Posts   1374 Views

Avatar
MCK

Community Member, 18 Posts

7 September 2011 at 3:12pm

ecommerce module 0.82 has featured products as a feature (no pun intended).

I can get the FeaturedProducts to work (<% If FeaturedProducts %>) but how do I get these products to appear when the parent page doesn’t have the products as children, e.g., the Home page would be a great place to display the featured products but I don’t want the Products as children of the Home page.

I think it is just a simple logic problem but I can’t get my head around it.

Graeme McKinstry

Avatar
lanks

Community Member, 61 Posts

23 September 2011 at 7:41pm

Hi

The best way to do this is:

1. Create a new page type for your home page e.g. HomePage
2. In the controller of the HomePage page type add a new function to get the featured products. This function won't rely on a relationship with itself to query the for the featured products rather it will just select the products that have been flagged as featured.

e.g.

function getFeaturedProducts(){
			return DataObject::get("Product","FeaturedProduct = 1", "", "");
	}