Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Display Order Problem - Product Info Pages

    Hi All,

    I have changed my product listing order for my category listing pages so that it orders my sort number and quantity.

    I changed the file

    /includes/index_filters/default_filter.php

    and changed a line in here to be:

    $listing_sql .= " order by p.products_sort_order, p.products_quantity desc";

    the problem I seem to have now is that if a customer clicks on the first product in the category listing, then from within the product info page clicks "next" i.e to view the next product, instead of showing the next product in the category list its showing a diffeent one completely? (I think I might be going in alphabetical order)..

    Where can I look to ensure the next previous will marry up with the order of products displayed in the listings?

    Many Thanks

    Phil

  2. #2
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Display Order Problem - Product Info Pages

    I've done some custom search "magic" at my store and realized when I read your post that you were absolutely right - the prev/next display always defaults to alphabetical display, even if that wasn't the requested listing order. Hadn't noticed that! Thank you for pointing it out. Now to see about fixing it.

    The three files that work together on the mechanics of this are, as you've found,

    includes/index_filters/default_filter.php
    includes/modules/product_listing_alpha_sorter.php
    includes/modules/product_prev_next.php

    All three of these should be in an override directory. The adjusted files would go into the following, where your_template would be changed to the name of your actual template.

    includes/index_filters/your_template/default_filter.php
    includes/modules/your_template/product_listing_alpha_sorter.php
    includes/modules/your_template/product_prev_next.php

    That said, you've already added your custom search criteria to default_filter.php. Good job! product_listing_alpha_sorter.php is for the dropdown menu display, to show what criteria the results are appearing by. Let me know if you'd care to change that and I'll show you how I did mine.

    The part that gave me trouble was getting the prev/next display to recognize the requested sort order. The default is alphabetical, and it's used in a switch case along with the rest of the order by options. Mine refused to switch no matter what I did, even if I removed the order by text from the query altogether - it still displayed in alphabetical order. I was able to get around this by starting a session in default_filter.php to pick up the order by text from either the user requested or default landing display.

    Seems to work great here. Let's see if it will work for you, too!

    In 1.3.9h, the core default_filter.php file contains the following block of code at approx. lines 21 - 25:

    PHP Code:
    if (isset($_GET['alpha_filter_id']) && (int)$_GET['alpha_filter_id'] > 0) {
        
    $alpha_sort " and pd.products_name LIKE '" chr((int)$_GET['alpha_filter_id']) . "%' ";
      } else {
        
    $alpha_sort '';
      } 
    You've probably added some additional lines for your preferred search criteria.

    Add the following immediately afterwards:

    PHP Code:
    // BOF ADJUST PREV/NEXT SORT ORDER DISPLAY
    session_start();
    $_SESSION['sort_order'] = $alpha_sort;
    // EOF ADJUST PREV/NEXT SORT ORDER DISPLAY 
    Next, in product_prev_next.php, the core file from 1.3.9h contains the following block of code at approx. lines 70 - 75:

    PHP Code:
    $sql "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order
              from   " 
    TABLE_PRODUCTS " p, "
      
    TABLE_PRODUCTS_DESCRIPTION " pd, "
      
    TABLE_PRODUCTS_TO_CATEGORIES " ptc
              where  p.products_status = '1' and p.products_id = pd.products_id and pd.language_id= '" 
    . (int)$_SESSION['languages_id'] . "' and p.products_id = ptc.products_id and ptc.categories_id = '" . (int)$current_category_id "'" .
      
    $prev_next_order
    Change this to:

    PHP Code:
    // BOF ADJUST PREV/NEXT SORT ORDER DISPLAY
      
    $sql "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order, p.products_date_added
    from   " 
    TABLE_PRODUCTS " p,
    TABLE_PRODUCTS_DESCRIPTION " pd,
    TABLE_PRODUCTS_TO_CATEGORIES " ptc
    where  p.products_status = '1'
    and p.products_id = pd.products_id
    and pd.language_id= '" 
    . (int)$_SESSION['languages_id'] . "'
    and p.products_id = ptc.products_id
    and ptc.categories_id = '" 
    . (int)$current_category_id "'
    $_SESSION['sort_order'];
    // EOF ADJUST PREV/NEXT SORT ORDER DISPLAY 
    That should do it. Hope this helps! :)
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

  3. #3
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Display Order Problem - Product Info Pages

    Replying again to say I just realized you're using a different variable than I am to set your order by options. Change the session to use yours, or change your order by text to use $alpha_sort. Either way should work.
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

  4. #4
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Display Order Problem - Product Info Pages

    Quote Originally Posted by ToniScraparoni View Post
    I've done some custom search "magic" at my store and realized when I read your post that you were absolutely right - the prev/next display always defaults to alphabetical display, even if that wasn't the requested listing order. Hadn't noticed that! Thank you for pointing it out. Now to see about fixing it.

    The three files that work together on the mechanics of this are, as you've found,

    includes/index_filters/default_filter.php
    includes/modules/product_listing_alpha_sorter.php
    includes/modules/product_prev_next.php

    All three of these should be in an override directory. The adjusted files would go into the following, where your_template would be changed to the name of your actual template.

    includes/index_filters/your_template/default_filter.php
    includes/modules/your_template/product_listing_alpha_sorter.php
    includes/modules/your_template/product_prev_next.php

    That said, you've already added your custom search criteria to default_filter.php. Good job! product_listing_alpha_sorter.php is for the dropdown menu display, to show what criteria the results are appearing by. Let me know if you'd care to change that and I'll show you how I did mine.

    The part that gave me trouble was getting the prev/next display to recognize the requested sort order. The default is alphabetical, and it's used in a switch case along with the rest of the order by options. Mine refused to switch no matter what I did, even if I removed the order by text from the query altogether - it still displayed in alphabetical order. I was able to get around this by starting a session in default_filter.php to pick up the order by text from either the user requested or default landing display.

    Seems to work great here. Let's see if it will work for you, too!

    In 1.3.9h, the core default_filter.php file contains the following block of code at approx. lines 21 - 25:

    PHP Code:
    if (isset($_GET['alpha_filter_id']) && (int)$_GET['alpha_filter_id'] > 0) {
        
    $alpha_sort " and pd.products_name LIKE '" chr((int)$_GET['alpha_filter_id']) . "%' ";
      } else {
        
    $alpha_sort '';
      } 
    You've probably added some additional lines for your preferred search criteria.

    Add the following immediately afterwards:

    PHP Code:
    // BOF ADJUST PREV/NEXT SORT ORDER DISPLAY
    session_start();
    $_SESSION['sort_order'] = $alpha_sort;
    // EOF ADJUST PREV/NEXT SORT ORDER DISPLAY 
    Next, in product_prev_next.php, the core file from 1.3.9h contains the following block of code at approx. lines 70 - 75:

    PHP Code:
    $sql "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order
              from   " 
    TABLE_PRODUCTS " p, "
      
    TABLE_PRODUCTS_DESCRIPTION " pd, "
      
    TABLE_PRODUCTS_TO_CATEGORIES " ptc
              where  p.products_status = '1' and p.products_id = pd.products_id and pd.language_id= '" 
    . (int)$_SESSION['languages_id'] . "' and p.products_id = ptc.products_id and ptc.categories_id = '" . (int)$current_category_id "'" .
      
    $prev_next_order
    Change this to:

    PHP Code:
    // BOF ADJUST PREV/NEXT SORT ORDER DISPLAY
      
    $sql "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order, p.products_date_added
    from   " 
    TABLE_PRODUCTS " p,
    TABLE_PRODUCTS_DESCRIPTION " pd,
    TABLE_PRODUCTS_TO_CATEGORIES " ptc
    where  p.products_status = '1'
    and p.products_id = pd.products_id
    and pd.language_id= '" 
    . (int)$_SESSION['languages_id'] . "'
    and p.products_id = ptc.products_id
    and ptc.categories_id = '" 
    . (int)$current_category_id "'
    $_SESSION['sort_order'];
    // EOF ADJUST PREV/NEXT SORT ORDER DISPLAY 
    That should do it. Hope this helps! :)
    bear with me.. trying to get my head around what this is doing..

  5. #5
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Display Order Problem - Product Info Pages

    LOL, Philip!

    You might want to take some more time, actually. The fix works great mechanically, but its throwing a debug error I can't seem to narrow down about a completely unrelated - and untouched - file. The error doesn't seem to affect how anything works, it's just annoying to clear the logs. I'll let you know when I figure it out.

    Also, I should take back what I said about interchanging the session variables. I posted before noticing the join operand in your variable. You'd wipe out the preceding part of the related queries if you were to use yours, so you'd have to change your variable to $alpha_sort or something else. Guess it's my way or the highway! LOL! ;)
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

  6. #6
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Display Order Problem - Product Info Pages

    Quote Originally Posted by ToniScraparoni View Post
    LOL, Philip!

    You might want to take some more time, actually. The fix works great mechanically, but its throwing a debug error I can't seem to narrow down about a completely unrelated - and untouched - file. The error doesn't seem to affect how anything works, it's just annoying to clear the logs. I'll let you know when I figure it out.

    Also, I should take back what I said about interchanging the session variables. I posted before noticing the join operand in your variable. You'd wipe out the preceding part of the related queries if you were to use yours, so you'd have to change your variable to $alpha_sort or something else. Guess it's my way or the highway! LOL! ;)
    haha thanks for the update! - I think I can live with it for now as annoying as it is, im pretty sure joe bloggs doesnt usually browse my products using the next and previous buttons anyway :o)

  7. #7
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Display Order Problem - Product Info Pages

    An update on this. I never did figure out what about these "modified sort" additions was throwing the debug error in includes/classes/category_tree.php, specifically referencing a call to a member function on a non-object on line 68. No changes had been made in that file. I went over the files I did change endlessly but couldn't find anything wrong. So, I wound up changing category_tree.php instead. ;)

    The error referenced line 68, but for me, the fix was on line 52. Line 52 used to be:

    PHP Code:
    while (!$categories->EOF)  { 
    Now it's this:

    PHP Code:
    while ($categories->EOF === false) { 
    After making that change, Supertracker decided to be ornery, giving the same "member function on a non-object" nonsense in its class file, includes/classes/supertracker.php. That one referenced line 100, then required a similar change on line 129. Those are as follows:

    Line 100 used to be:

    PHP Code:
    if ($_SESSION['cart']->count_contents() > 0) { 
    Line 100 now:

    PHP Code:
    if (!empty($_SESSION['cart']->contents)) { 
    Line 129 original code:

    PHP Code:
    if ($_SESSION['cart']->count_contents() > 0$tracking_data->fields['added_cart'] = 'true'
    The new line 129:
    PHP Code:
    if (!empty($_SESSION['cart']->contents)) $tracking_data->fields['added_cart'] = 'true'
    This seems to have solved the debug problem. Supertracker appears to function properly and the cache has been blissfully clear. Woo! :)
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

 

 

Similar Threads

  1. v139f Footer not showing up on product info display pages
    By aspapi in forum General Questions
    Replies: 6
    Last Post: 11 Dec 2012, 06:53 PM
  2. v150 Having different product info display pages
    By Baron5 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 10 Jun 2012, 12:18 AM
  3. Stop sidebar banner display on product info pages
    By matt123 in forum Basic Configuration
    Replies: 1
    Last Post: 4 Jan 2008, 08:57 AM
  4. Product Info display problem, IE vs Firefox
    By stumped in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 25 Oct 2006, 12:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg