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

Problem With Pagination!!!!


Go to End


2 Posts   1372 Views

Avatar
jim4nz

Community Member, 5 Posts

11 June 2010 at 11:10am

Edited: 11/06/2010 1:14pm


Hi guys basically this is my structure
http://pastie.org/1000170

-------- 1.1 layer Product Group
        -------- 2.1 layer Product Group
                        ProductItem 1
                        ProductItem 2
                        ProductItem 3

        -------- 2.2 layer Product Group
                        ProductItem 4
                        ProductItem 5
                        ProductItem 6
-------- 1.2 layer Product Group
        -------- 2.3 layer Product Group
                        ProductItem 7
                        ProductItem 8
                        ProductItem 9

        -------- 2.4 layer Product Group
                        ProductItem 10
                        ProductItem 11
                        ProductItem 12

when i click on layer 1.1 i wanna be able to see productitem from 1-6 with pagaination (Pagination not working)
when i click on layer 1.2 i wanna be able to see productitem from 7-12 with pagaination (Pagination not working)
and
when i click into 2.1 layer i will be able to see productitem from 1-3 with pagination (working perfectly)
when i click into 2.2 layer i will be able to see productitem from 4-6 with pagination (working perfectly)
when i click into 2.3 layer i will be able to see productitem from 7-9 with pagination (working perfectly)

however some how the layer 1 pagination is not working
but second layer is working fine
this is the code i'm using http://pastie.org/1000178

<?php         
        /** 
	 * Return ProductGroups as children of the current page
	 */         
         function ChildGroups() {

		return DataObject::get("ProductGroup", "ShowInMenus = 1 AND ParentID = " . $this->ID);
	
         }
	

	/**
	 * Returns the Products as children of the current page.
	 */
	public function ChildProducts() {
		return DataObject::get("Product", "ShowInMenus = 1 AND ParentID = " . $this->ID);
		
	}
	
	/**
	 * Returns the Products as children of the current page with pagination.
	 */
	
	function ProductListPagination() {
		
		if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
		$SQL_start = (int)$_GET['start'];
		$doSet = DataObject::get(
			$callerClass = "Product",
			$filter = "`ParentID` = '".$this->ID."'",
			$sort = "",
			$join = "",
			$limit = "{$SQL_start},2"
		);
		
		return $doSet ? $doSet : false;
	}
?>


         /**
	 * Silverstripe code, to display the Product list for Layer 1!!
	 */

<% if ChildGroups %>
			<div class="product_summary">
				
				<% control level(3) %>	
					<ul id="ProductList">
						<% control ChildGroups %>
							<% if ChildProducts %>
								<% control ProductListPagination %>
										<% include ProductGroupItem %>
								<% end_control %>
							<% end_if %>
						<% end_control %>
					</ul>
				<% end_control %>
			</div>
<% end_if %>

Avatar
jim4nz

Community Member, 5 Posts

11 June 2010 at 1:04pm

hi guys
i did the following test

if i hard code the 2 layer's parent id in, like the following

function ProductListPagination() {
		
		if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
		$SQL_start = (int)$_GET['start'];
		$doSet = DataObject::get("Product", "`ParentID` = 19 OR `ParentID` = 21", "", "",  "{$SQL_start},2");
		
		return $doSet ? $doSet : false;
	}

the pagination will work but it will display the product item twice!!! @@....... any solution ?