Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39
  1. #31
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: How do I list products in sub category with in the parent category?

    Quote Originally Posted by balihr View Post
    OK, I just read Chad's post again and although I confirmed it's exactly what it does, I think I misinterpreted what he had said...

    @Feznizzle - both answers are NO. This mod does NOT have products and categories on the same level. Instead, what it does is that it will list all products from that level's subcategories on one page (or multiple paginated pages, of course). BTW, your quest #1 seems like standard Zen Cart... Maybe I'm missing something, dunno...

    Anyways... I've tried to draw what this mod would do. At the top of the image, you can see the category structure. The middle right section is what this mod is all about. It keeps the category structure intact, you don't need to have products and subcategories on the same level. It will only display all products that exist in the lower hierarchy level(s).



    I hope I'm making sense and that I've (finally) managed to explain what it does...
    Nope, you just over explained it and I'm completely confused now.

    So basically the category - sub category hierarchy is untouched.

    But now on a categories sub-category page is a new "product listing page" that includes all the categories sub-categories products where I can view them without clicking sub-category after sub-category before I actually get to the sub-categories "products listing page".

    But if I wanted to view specific products from the categories sub-category page with the new "product listing page" of all the categories sub-categories products I could still click a sub-category which will bring me to the categories sub-category "product listing page" with only that sub-categories products.

    Not sure, but I think I'm still completely lost here.
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  2. #32
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: How do I list products in sub category with in the parent category?

    @rbarbour - uhm... I thought I sent you a copy of the mod earlier...

    But, yeah, I think your explanation is spot on. Although I'm having trouble understanding it myself I'd say you explained it right. It's quite hard to imagine it, I understand that, I'll see if I can find enough time to setup a live demo in the next few days...

  3. #33
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: How do I list products in sub category with in the parent category?

    Quote Originally Posted by balihr View Post
    @rbarbour - uhm... I thought I sent you a copy of the mod earlier...

    But, yeah, I think your explanation is spot on. Although I'm having trouble understanding it myself I'd say you explained it right. It's quite hard to imagine it, I understand that, I'll see if I can find enough time to setup a live demo in the next few days...
    You did and I'm just getting around to playing with it and it would be a greatly sought after addition to zen cart, I'm loving it.
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  4. #34
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: How do I list products in sub category with in the parent category?

    Thanks for the image and further explanation. That's in line with what I thought you were saying.

    Regarding my Q#1, that was poorly put... sorry!

    I can use your flow chart to better phrase the question. On the right, the very first position (With Mod, clicked on "parent", browsing parent category). I was hoping there would be a way to only display products from Sub1 and Sub2, unless the visitor clicked on Sub3.

    So say Sub1 contains 10 Red Products, Sub2 contains 10 Blue Products, and Sub3 contains 5000 Parts for repairing Blue and Red Products.

    But NM. Just ignore that. I dig the idea behind the project, would love to give it a go. I think I read that you wanted those interest in testing to PM you, so I'll do that now.

  5. #35
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: How do I list products in sub category with in the parent category?

    Quote Originally Posted by Feznizzle View Post
    Thanks for the image and further explanation. That's in line with what I thought you were saying.

    Regarding my Q#1, that was poorly put... sorry!

    I can use your flow chart to better phrase the question. On the right, the very first position (With Mod, clicked on "parent", browsing parent category). I was hoping there would be a way to only display products from Sub1 and Sub2, unless the visitor clicked on Sub3.
    This COULD be done, but it would require some custom work. You could add a flag on the categories you want to exclude, and then add the logic to skip those "flagged" categories from displaying it under the sub-cat listing. Just an idea, you might be able to make it even better.

    Quote Originally Posted by Feznizzle View Post
    But NM. Just ignore that. I dig the idea behind the project, would love to give it a go. I think I read that you wanted those interest in testing to PM you, so I'll do that now.
    Replied to your PM - you can get the plugin from my site. I'll be releasing it here in a couple days, just need to write some documentation for it.

  6. #36
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: How do I list products in sub category with in the parent category?

    I too would like to test your plugin as well - I believe this was something that I was looking for a while back - but didn't find your thread - sorry about that - if you are still wanting testers please let me know

    I did look at your website for a copy of the plugin but couldn't find it

    FOUND IT!! thank you looks exceedingly useful!!!
    Last edited by SarahL; 24 May 2016 at 04:58 PM.

  7. #37
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: How do I list products in sub category with in the parent category?

    Took a gander at some of the involved code to apply this as I think others have been looking such that when looking at a category that has sub-categories it is possible to "add" a product to that category and display both the sub-categories and the product(s) in the center screen.

    Could be applied as a "plugin" such that current files would not require modification, but the whole thing could be additional code.

    Primarily, includes/modules/pages/index/header_php.php currently evaluates the current category_id (this was I think while looking at ZC 1.5.5 code). If the current category_id has product listed in it then just the products designation is sent along to be processed by downstream code. Currently if a category has multiple categories with it then that results in a page style to be displayed, if that category doesn't have anything further associated with it then it's treated as an empty product display.

    Anyways, with a little further "care" the evaluation could go if there are product, then evaluate if there are also categories. Then direct to a "template" file that handles display of both. I would (as I believe I have in other similar threads) still keep the "category" structure as originally coded but then link the product desired to be displayed in this "merged" category display. That way the pricing structure remains untouched and the product is just simply "managed" as to where it should be displayed. Of course then comes in things like sort order, sequencing, percentage of each category/product to display, etc... but guess it's a start.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #38
    Join Date
    Jun 2007
    Posts
    474
    Plugin Contributions
    2

    Default Re: How do I list products in sub category with in the parent category?

    I apologize for resurrecting a 2 year old thread, but I'm working on this problem now so figured I would post some of the solutions I have.

    As a rehash, the goal is that when clicking on a category that contains sub categories, the category page will at a minimum display all the products from the sub categories (it might also display the sub category names, and other things.)

    From a page load perspective you could argue this is poor practice. From a user experience perspective I would argue this is very helpful - especially if the subcategories are numerous and the number of products in each subcategory is small.

    Most users now anticipate being able to shop/view this way and naturally want to scroll due to the UI of mega sites such as Pinterest, Instagram, Facebook, etc.

    Solutions I have Found:
    1. One solution is built into the Tableau 1 template by Numinix. Pros: it also includes additional sort options like 'most popular'. Cons: it isn't standalone, it impacts core files such as modules/pages/index/header.php and more (plus requires a lot of extra files)

    2. In this thread: https://www.zen-cart.com/showthread....ts-on-one-page yellow1912 posted a download. This sort of works, but the sql code is incorrect and causes all products (of the entire store) to load. This is fixable with some sql changes, but not really worth going into in this post.

    3. Balihr mentioned in this thread he had a solution, but it wasn't posted so you can message him directly.

    4. The easiest solution I found is to use the existing stuff of Zen-Cart that already does this. That would be the new products, featured products, and specials modules that appear on category and subcategory pages. Pros: pretty straightforward and using similar structure to existing code Cons: pagination isn't built in.

    Here are the quick instructions without utilizing Admin switches. I'm using responsive_classic template and using the module name all_cats_all_products. These instructions have been written as though you have some knowledge of navigating the Zen-Cart files.

    1. Add to includes/filenames.php define('FILENAME_ALL_CATS_ALL_PRODUCTS', 'all_cats_all_products.php');

    2. Create the new file 'includes/templates/responsive_classic/tpl_modules_all_cats_all_products.php' this will mirror 'includes/templates/template_default/tpl_modules_whats_new.php' (or your already custom version) with some small changes. You will need to adjust if you have already customized this file.

    3. Make the file contents:
    Code:
    <?php
    /**
     * Module Template
     *
     * @package templateSystem
     * @copyright Copyright 2003-2005 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: tpl_modules_all_cats_all_products.php
     */
      include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ALL_CATS_ALL_PRODUCTS));
    ?>
    
    <!-- bof: all_cats_all_products -->
    <div class="centerBoxWrapper" id="allcatsallproducts">
    <?php
      require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
    ?>
    </div>
    <!-- eof: all_cats_all_products -->
    4. Create the new file 'includes/modules/all_cats_all_products.php' this will mirror 'includes/modules/new_products.php' (or your already custom version) with some small changes. You will need to adjust if you have already customized this file.

    5. Note - in an effort to match the styling of featured products, new products, and specials, and minimize database changes, this file still pulls some settings from admin that correlate to new_products. For instance it uses the new products columns per row setting, etc.

    5. Make the file contents:
    Code:
    <?php
    /**
     * all_cats_all_products.php module
     *
     * @package modules
     * @copyright Copyright 2003-2008 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: all_cats_all_products.php 8730 2008-06-28 01:31:22Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    
    // initialize vars
    $categories_products_id_list = '';
    $list_of_products = '';
    $all_cats_all_products_query = '';
    
    if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($all_cats_all_products_category_id) || $all_cats_all_products_category_id == '0') ) {
      $all_cats_all_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                               and   p.products_status = 1 ";
    } else {
      // get all products and cPaths in this subcat tree
      $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0);
    
      if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        // build products-list string to insert into SQL query
        foreach($productsInCategory as $key => $value) {
          $list_of_products .= $key . ', ';
        }
        $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
    
        $all_cats_all_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id,p.products_calories, p.products_netcarbs, p.products_smartdietcount
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                               and p.products_status = 1
                               and p.products_id in (" . $list_of_products . ")";
      }
    }
    
    if ($all_cats_all_products_query != '') $all_cats_all_products = $db->ExecuteRandomMulti($all_cats_all_products_query, 5000);
    
    $row = 0;
    $col = 0;
    $list_box_contents = array();
    $title = '';
    
    $num_products_count = ($all_cats_all_products_query == '') ? 0 : $all_cats_all_products->RecordCount();
    
    // show only when 1 or more
    if ($num_products_count > 0) {
      if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) {
        $col_width = floor(100/$num_products_count);
      } else {
        $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }
    
      while (!$all_cats_all_products->EOF) {
        $products_price = zen_get_products_display_price($all_cats_all_products->fields['products_id']);
        if (!isset($productsInCategory[$all_cats_all_products->fields['products_id']])) $productsInCategory[$all_cats_all_products->fields['products_id']] = zen_get_generated_category_path_rev($all_cats_all_products->fields['master_categories_id']);
    
        $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
        'text' => (($all_cats_all_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($all_cats_all_products->fields['products_id']), 'cPath=' . $productsInCategory[$all_cats_all_products->fields['products_id']] . '&products_id=' . $all_cats_all_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $all_cats_all_products->fields['products_image'], $all_cats_all_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($all_cats_all_products->fields['products_id']), 'cPath=' . $productsInCategory[$all_cats_all_products->fields['products_id']] . '&products_id=' . $all_cats_all_products->fields['products_id']) . '">' . $all_cats_all_products->fields['products_name'] . '</a><br />' . $products_price);
    
        $col ++;
        if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) {
          $col = 0;
          $row ++;
        }
        $all_cats_all_products->MoveNextRandom();
      }
    
          $title = '<h2 class="centerBoxHeading">' . $current_categories_name . '</h2>';
    }
    ?>
    6. Copy includes/templates/template_default/tpl_index_categories.php (or your already custom version) and save as includes/templates/responsive_classic/tpl_index_categories.php

    7. In tpl_index_categories.php insert the following where you want the products to display on the category page:
    Code:
    <?php require($template->get_template_dir('tpl_modules_all_cats_all_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_all_cats_all_products.php'); ?>
    8. If you want this to appear on the index page do the same for tpl_index_default.php I would suggest not doing that, unless you have a very small number of products in which case you should just feature all the products in the featured products module and set that to appear on the home page.

  9. #39
    Join Date
    Jun 2007
    Posts
    474
    Plugin Contributions
    2

    Default Re: How do I list products in sub category with in the parent category?

    Looks like the code for the second file (includes/modules/all_cats_all_products.php_ should be what I posted below instead. I attempted to change all instances of 'new_products' to 'all_cats_all_products' but my changes caused all products to appear, not just subcategories. This code could be buttoned up some, but will suffice.

    Code:
    <?php/**
     * new_products.php module
     *
     * @package modules
     * @copyright Copyright 2003-2008 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: new_products.php 8730 2008-06-28 01:31:22Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    
    
    // initialize vars
    $categories_products_id_list = '';
    $list_of_products = '';
    $new_products_query = '';
    
    
    $display_limit = zen_get_new_date_range();
    
    
    if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
      $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                               and   p.products_status = 1 ";
    } else {
      // get all products and cPaths in this subcat tree
      $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0);
    
    
      if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        // build products-list string to insert into SQL query
        foreach($productsInCategory as $key => $value) {
          $list_of_products .= $key . ', ';
        }
        $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
    
    
        $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                               and p.products_status = 1
                               and p.products_id in (" . $list_of_products . ")";
      }
    }
    
    
    if ($new_products_query != '') $new_products = $db->ExecuteRandomMulti($new_products_query, 5000);
    
    
    $row = 0;
    $col = 0;
    $list_box_contents = array();
    $title = '';
    
    
    $num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount();
    
    
    // show only when 1 or more
    if ($num_products_count > 0) {
      if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) {
        $col_width = floor(100/$num_products_count);
      } else {
        $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }
    
    
      while (!$new_products->EOF) {
        $products_price = zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);
    
    
        $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
        'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price);
    
    
        $col ++;
        if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) {
          $col = 0;
          $row ++;
        }
        $new_products->MoveNextRandom();
      }
    
    
      if ($new_products->RecordCount() > 0) {
        if (isset($new_products_category_id) && $new_products_category_id != 0) {
          $category_title = zen_get_categories_name((int)$new_products_category_id);
          $title = '<h2 class="centerBoxHeading">' . $category_title . '</h2>';
        } else {
          $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h2>';
        }
        $zc_show_new_products = true;
      }
    }
    ?>

 

 
Page 4 of 4 FirstFirst ... 234

Similar Threads

  1. Replies: 7
    Last Post: 24 Nov 2012, 06:33 AM
  2. v139h How do I bulk-move all products from Sub-Category into a parent Category?
    By shags38 in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 28 Jun 2012, 07:19 PM
  3. Sub-category Images in on Parent Category Page
    By caesartrading in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 25 Jul 2010, 04:57 PM
  4. Display products list of the sub-category
    By HellMind in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 27 Aug 2009, 08:21 PM
  5. Category with no products dont display"There are no products to list in this category
    By atracksler in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 3 Apr 2008, 05:47 AM

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