Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    2
    Plugin Contributions
    0

    Default Other products from same category listed in product info

    Hello guys,

    I'm wondering if there's an easy to list products from the same category as a product that you are viewing. I saw the cross sell modification, but I didn't want to go in and have to link up all of the products manually. A small view of random products from the same category would suit me better.

    Thanks!

  2. #2
    Join Date
    Jul 2007
    Posts
    2
    Plugin Contributions
    0

    Default Re: Other products from same category listed in product info

    Has anyone done this before?

  3. #3
    Join Date
    Sep 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Other products from same category listed in product info

    In fact, I'm dealing with the same problem right about now. I'm also trying to display both product details with other same category products on the same page. No idea how to achieve that. Any help?

  4. #4
    Join Date
    Sep 2007
    Posts
    27
    Plugin Contributions
    0

    Default Re: Other products from same category listed in product info

    is there a way to do this, because i am interested too!

  5. #5
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Other products from same category listed in product info

    Easy enough. Add this code to the end of your includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display file:

    PHP Code:
    <?php
      
    /* This code adds a products listing to the bottom of products_info pages
       * containing other products in this category. It is similar to Featured
       * or New Products.
       *
       * I use the class centerBoxContentsFeatured and id featuredProducts for 
       * convenience, I would recommend removing those and using the class
       * centerBoxContentsThisCategory and id thisCategoryProducts is your css.
       */

      // setup constants here
      
    define('MAX_DISPLAY_SEARCH_RESULTS_THIS_CATEGORY'9);
      
    define('SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS'3);
      
    define('IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_WIDTH'100);
      
    define('IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_HEIGHT'80);
      
    define('TABLE_HEADING_THIS_CATEGORY_PRODUCTS''Other Products in This Category');

      include(
    DIR_WS_MODULES 'pages/index/header_php.php');

      
    $products_query "select distinct p.products_id, p.products_image, pd.products_name
                               from (" 
    TABLE_PRODUCTS " p
                               left join " 
    TABLE_PRODUCTS_DESCRIPTION " pd on p.products_id = pd.products_id), " .
      
    TABLE_PRODUCTS_TO_CATEGORIES " p2c, " .
      
    TABLE_CATEGORIES " c
                               where p.products_id = p2c.products_id
                               and p2c.categories_id = c.categories_id
                               and c.categories_id = '" 
    . (int)$current_category_id "'
                               and p.products_id != '" 
    . (int)$_GET['products_id'] . "' 
                               and p.products_id = pd.products_id and p.products_status = 1 and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'";

    $products_this_category $db->ExecuteRandomMulti($products_queryMAX_DISPLAY_SEARCH_RESULTS_THIS_CATEGORY);

    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';

    $num_products_count $products_this_category->RecordCount();

    // show only when 1 or more
    if ($num_products_count 0) {
      if (
    $num_products_count SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS) {
        
    $col_width floor(100/$num_products_count);
      } else {
        
    $col_width floor(100/SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS);
      }
      while (!
    $products_this_category->EOF) {

        
    $products_price zen_get_products_display_price($products_this_category->fields['products_id']);

        
    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centerBoxContentsThisCategory centeredContent back"' ' ' 'style="width:' $col_width '%;"',
        
    'text' => (($products_this_category->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' '<a href="' zen_href_link(zen_get_info_page($products_this_category->fields['products_id']), 'products_id=' $products_this_category->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $products_this_category->fields['products_image'], $products_this_category->fields['products_name'], IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_WIDTHIMAGE_THIS_CATEGORY_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' zen_href_link(zen_get_info_page($products_this_category->fields['products_id']), 'products_id=' $products_this_category->fields['products_id']) . '">' $products_this_category->fields['products_name'] . '</a><br />' $products_price);

        
    $col ++;
        if (
    $col > (SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS 1)) {
          
    $col 0;
          
    $row ++;
        }
        
    $products_this_category->MoveNextRandom();
      }

      if (
    $products_this_category->RecordCount() > 0) {
        
    $title '<h2 class="centerBoxHeading">' TABLE_HEADING_THIS_CATEGORY_PRODUCTS '</h2>';
        
    $zc_show_featured true;
      }
    }
    ?>



    <!-- bof: products_this_category -->
    <div class="centerBoxWrapper" id="featuredProducts thisCategoryProducts">
    <?php
      
    require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE$current_page_base,'common'). '/tpl_columnar_display.php');
    ?>
    </div>
    <!-- eof: products_this_category -->
    Note that this has NOT been thoroughly tested and you should test it on a testing site before employing it on a live site.

    BrandTim

  6. #6
    Join Date
    Sep 2007
    Posts
    27
    Plugin Contributions
    0

    Default Re: Other products from same category listed in product info

    Quote Originally Posted by brandtim View Post
    Easy enough. Add this code to the end of your includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display file:

    Note that this has NOT been thoroughly tested and you should test it on a testing site before employing it on a live site.

    BrandTim
    Wow, works a treat!

    You rock!!

 

 

Similar Threads

  1. v154 Other products from same category listed in product info
    By chadlly2003 in forum General Questions
    Replies: 1
    Last Post: 10 Dec 2015, 05:27 PM
  2. Show other products from subcategory under product info?
    By Danielle in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 27 Sep 2010, 08:31 AM
  3. Replies: 3
    Last Post: 11 May 2009, 03:54 AM
  4. New Products Sidebox: Same Product Listed Twice
    By MeltDown in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 20 Apr 2009, 09:36 PM
  5. 4 Random Products from same category at the bottom of Product Info page
    By dara108 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 2 Jan 2009, 10:58 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR