Results 1 to 5 of 5
  1. #1

    Default All Products from sub-categories on Parent Category

    Hello, this question is not answered anywhere so here it is.

    It will be very nice to have products on category page with subcategories , from those subcategories which the parrent category holds.

    By the way I managed to have that done but with many bugs (for now).

    In default_filter just after // We show them all

    my code looks like this:

    PHP Code:
    {
    $categories $db->Execute("SELECT c.categories_id,c.parent_id
                                                FROM " 
    TABLE_CATEGORIES " c
                                                WHERE c.parent_id = " 
    . (int)$current_category_id "
                                                );
                
    $LCatID = '';
                foreach (
    $categories as $category) {
                    
    $categories_count++;
                    
    $rows++;
                    
    $LCatID .= $category['categories_id'].',';
                }
    if (
    $LCatID ==! null ){$mCatID rtrim($LCatID',');}else { $mCatID =(int)$current_category_id;}

            // We show them all
            
    $listing_sql = "SELECT DISTINCT " . $select_column_list . " p.products_idp.products_typep.master_categories_id,s.expires_date as expires_dates.status as status,
            
    p.manufacturers_idp.products_pricep.products_tax_class_idpd.products_description, IF(s.status 1,
            
    s.specials_new_products_priceNULL) as specials_new_products_price, IF(s.status =1s.specials_new_products_price,
            
    p.products_price) as final_pricep.products_sort_orderp.product_is_callp.product_is_always_free_shipping,
            
    p.products_qty_box_status";
            
            
    $listing_sql .= " FROM " . TABLE_PRODUCTS . " p" .
            " 
    LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id s.products_id" .
            " 
    LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id pd.products_id" .
            " 
    LEFT JOIN " . TABLE_MANUFACTURERS . " m on p.manufacturers_id m.manufacturers_id" .
            " 
    JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id p2c.products_id" .
            (
    $filter_attr == true ? " JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " p2a on p.products_id p2a.products_id" .
            " 
    JOIN " . TABLE_PRODUCTS_OPTIONS . " po on p2a.options_id po.products_options_id" .
            " 
    JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on p2a.options_values_id pov.products_options_values_id" .
            (defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " 
    JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as on p.products_id p2as.products_id " : "") : '');
            
    $listing_sql .= " WHERE p2c.categories_id in (" . $mCatID . ")  
            and 
    pd.language_id '" . (int)$_SESSION['languages_id'] . "'
            
    and p.products_status 1" .
            
    $filter .
            
    $alpha_sort.
            " 
    GROUP BY p.products_id " .
            
    $having;
            
        } 
    there $mCatID as you see returns list of all children categories wich the parent hods, and i just add this list when the category is parrent instead of $current_category_id = p2c.categories_id as there is no p2c.categories_id on parent categorries.

    And this wok for the part that there is list of all products with links to them exept that it returns those results without images, without product_name and so on. And the link of the product have some wierd parameters like:

    www.website.com/product_url?1701_4

    1701_4 is probably my category and its subcategory, but the funiset thing is that the link is working fine.

    I supose there is a lot more to edit to make this work like I need it. But hey there must be some easy fix that I can't think of, so if somebody can help me with that I will be very happy as well some others like me having the same wish come true.

    Kind regards and many thanks to everybody.
    Last edited by perfumbg; 17 Nov 2020 at 11:02 PM.
    My most recent work: magprom.net

  2. #2

    Default Re: All Products from sub-categories on Parent Category

    Now I have the LOG.

    Code:
    [24-Nov-2020 10:29:44 Europe/Sofia] Request URI: /prahosmukachki, IP address: 94.190.193.162
    #1  sizeof() called at [/home/xxxxxxxxx/public_html/includes/modules/goodwin/product_listing.php:362]
    
    #2  include(/home/xxxxxxxxx/public_html/includes/modules/goodwin/product_listing.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_modules_product_listing.php:11]
    
    #3  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_modules_product_listing.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_index_categories.php:99]
    
    #4  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_index_categories.php) called at [/home/xxxxxxxxx/public_html/includes/modules/pages/index/main_template_vars.php:235]
    
    #5  require(/home/xxxxxxxxx/public_html/includes/modules/pages/index/main_template_vars.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/common/tpl_main_page.php:97]
    
    #6  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/common/tpl_main_page.php) called at [/home/xxxxxxxxx/public_html/index.php:101]
    --> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxxxxxxxx/public_html/includes/modules/goodwin/product_listing.php on line 362.
    
    [24-Nov-2020 10:29:44 Europe/Sofia] Request URI: /prahosmukachki, IP address: 94.190.193.162
    #1  include(/home/xxxxxxxxx/public_html/includes/modules/goodwin/product_listing.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_modules_product_listing.php:11]
    #2  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_modules_product_listing.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_index_categories.php:99]
    #3  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/templates/tpl_index_categories.php) called at [/home/xxxxxxxxx/public_html/includes/modules/pages/index/main_template_vars.php:235]
    #4  require(/home/xxxxxxxxx/public_html/includes/modules/pages/index/main_template_vars.php) called at [/home/xxxxxxxxx/public_html/includes/templates/goodwin/common/tpl_main_page.php:97]
    #5  require(/home/xxxxxxxxx/public_html/includes/templates/goodwin/common/tpl_main_page.php) called at [/home/xxxxxxxxx/public_html/index.php:101]
    --> PHP Warning: Use of undefined constant TABLE_HEADING_MODEL - assumed 'TABLE_HEADING_MODEL' (this will throw an Error in a future version of PHP) in /home/xxxxxxxxx/public_html/includes/modules/goodwin/product_listing.php on line 594.
    The problem seems to be the sizeof() from default_filter.php, any ideas anybody?
    My most recent work: magprom.net

  3. #3

    Default Re: All Products from sub-categories on Parent Category

    Also I have found something wich may cause the missing name,image,price:

    On master category when I echo ($column_list[$col]) the result is NOTHING

    ON subcategory it returns PRODUCT_LIST_MODEL

    Which means there should be some triger to turn this on...
    My most recent work: magprom.net

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: All Products from sub-categories on Parent Category

    This situation is a common occurrence from some old templates which created overrides of core files but haven't been kept up to date with newer Zen Cart code.
    I see it most often with picaflor templates and things that change the product_listing module or default_filter.

    Best course of action is to compare all your non-core files with the core equivalents and merge in whatever updates are missing, and inspect whatever changes were made to ensure they're sensible.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5

    Default Re: All Products from sub-categories on Parent Category

    Quote Originally Posted by DrByte View Post
    This situation is a common occurrence from some old templates which created overrides of core files but haven't been kept up to date with newer Zen Cart code.
    I see it most often with picaflor templates and things that change the product_listing module or default_filter.

    Best course of action is to compare all your non-core files with the core equivalents and merge in whatever updates are missing, and inspect whatever changes were made to ensure they're sensible.
    You are right as allways, I am using the architecture of an themplate from themeforest. And they have their own functions to retrieve some variables.

    I will compare the original vs custom themplate files.

    Thank you.
    My most recent work: magprom.net

 

 

Similar Threads

  1. v154 How do I list products in sub category with in the parent category?
    By JoeToys in forum Setting Up Categories, Products, Attributes
    Replies: 38
    Last Post: 2 Dec 2018, 08:54 PM
  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. Show all products form sub categories in category?
    By nidkolio in forum General Questions
    Replies: 3
    Last Post: 2 Nov 2009, 09:29 PM
  4. Display All Products from Selected Category - with Sub-Categories?
    By tomgsd in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 15 Apr 2009, 11:56 PM
  5. Display all products from sub-categories from parent link?
    By magneteye in forum General Questions
    Replies: 2
    Last Post: 2 Mar 2008, 11:36 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