Jump to:

2076 Posts in 857 Topics by 449 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Problem With Pagination!!!!

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, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 764 Views
  • jim4nz
    Avatar
    Community Member
    5 Posts

    Problem With Pagination!!!! Link to this post

    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 %>

  • jim4nz
    Avatar
    Community Member
    5 Posts

    Re: Problem With Pagination!!!! Link to this post

    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 ?

    764 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.