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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Product Group pages nested products..


Go to End


6 Posts   1921 Views

Avatar
Kiwipearls

Community Member, 34 Posts

23 February 2012 at 5:17pm

Edited: 23/02/2012 5:18pm

Hi there,

The site I am working on using Ecommerce 0.8.1 and SS 2.4.6.

I want the top level product group - to be the first page, introducing our online shop and what type of products they can find here.

But I do not want any lower product level group products to be displayed on this page. Just only on the next level group pages.

How do I achieve this?

Products <<--- do not want products displayed on this product group page - just the text
-2nd product group <<--- only want products displayed on the this level product group pages
- Product in 2nd product group <<- Normal product page, displaying normally
- Another product in 2nd product group
- 3rd product group
- product in 3rd product group

I hope this makes sense to you as it does to me.

Here is my Layout/ProductGroup.ss page

<h2 class="pageTitle">
		$Title
	</h2>	

	<% if Content %>
		<div class="typography">
			$Content
		</div>
	<% end_if %>
	
		
	<% if Products %>
		<div id="Products" class="category">
			<div class="resultsBar typography">
				<% if SortLinks %><span class="sortOptions">Sort by <% control SortLinks %><a href="$Link" class="sortlink $Current">$Name</a> <% end_control %></span><% end_if %>
			</div>
			<div class="clear"><!-- --></div>
			<div id="productList">
			
				<% control Products %>
					<% include ProductGroupItem %>
				<% end_control %>
			</div>
			<div class="clear"><!-- --></div>
		</div>
	<% end_if %>
	
	<% if IsTopLevel %>
	
			<% if ChildGroups %>
			
				<% if ChildProducts %>
					<ul class="list first">
						<% control ChildProducts %>
						<% end_control %>
					</ul>
				<% end_if %>
				<% control ChildGroups %>
					<% if ChildGroups %>
						<h3 class="productGroupTitle"><a href="$Link" title="<% sprintf(_t("VIEWGROUP","View the product group &quot;%s&quot;"),$Title) %>">$Title</a></h3>
						<ul class="list first">
							<% control ChildGroups %>
								<% if ChildProducts %>
								<% end_if %>
							<% end_control %>
						</ul>
					<% end_if %>
				<% end_control %>
			
		<% else %>
			
				<% if ChildProducts %>
					<ul class="list first">
						<% control ChildProducts %>
							<% end_control %>
					</ul>
				<% end_if %>
			
		<% end_if %>
	<% end_if %>
 

I eagerly look forward to hearing from someone on this.

Kind Regards
KP

Avatar
Kiwipearls

Community Member, 34 Posts

8 May 2012 at 12:14pm

I really wish someone could answer this for me or point me in the right direction. I have still not figured out how to do this.

Complete nub when it comes to coding, I try my best, but it is still gobbly gook at times.

Avatar
Jedateach

Forum Moderator, 238 Posts

8 May 2012 at 2:58pm

Hi KP, sorry I missed this post,

I'm not sure I fully understand, but I think I do understand you want a different template for your homepage.

You could achieve this by creating a HomePage class like this:

mysite/code/HomePage.php

class HomePage extends ProductGroup{
    ...
}
class HomePage_Controller extends ProductGroup_Controller{
   ..
} 

mysite/templates/Layout/HomePage.ss or themes/mytheme/templates/Layout/HomePage.ss

/// your template code here

Note that ProductGroup has been renamed to ProductCategory in the latest version of the code.

hope this helps,
Jeremy

Avatar
Kiwipearls

Community Member, 34 Posts

11 May 2012 at 8:13am

Hi there,

I guess I didn't word my post properly.

The products page - that says "This is the top level products page, it uses the product group page type, and it allows you to show your products checked as 'featured' on it. It also allows you to nest product group pages inside it."

It displays all the products, but I do not want it too.

I only want to show the products when users click on the productgroup/category pages I have created underneath it.

For example my tree is:

Products
-- Hosting
-- Domains

Do not want to display any products on the products page - only the hosting and the domain pages - but if I remove some code to remove products displaying on the products page, then you can't see products on the hosting or domains product group pages.

Avatar
Jedateach

Forum Moderator, 238 Posts

11 May 2012 at 11:28am

Hi KP,

I assume you just want to show featured products, like it says :) (that default content is a bit outdated)

Here are some new docs for you:
http://demo.ss-shop.org/docs/developer/en/Recipes/FeaturedProducts

regards,
Jeremy

Avatar
Kiwipearls

Community Member, 34 Posts

11 May 2012 at 6:24pm

Yes, but not on the home page, on the productgroup.ss page that comes with ecommerce.

I guess for now I will just have to put up with it.

Because if I edit that page, I get no products displaying on the group pages.