driven22 Posted November 3, 2018 Share Posted November 3, 2018 Hi, where is "Show Category Counts " in Oscommerce CE ? I would like to show in category box number of products like in previous version oscmmerce 2.3.4. In general.php i have: // Return the number of products in a category // TABLES: products, products_to_categories, categories function tep_count_products_in_category($category_id, $include_inactive = false) { $products_count = 0; if ($include_inactive == true) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'"); } else { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'"); } $products = tep_db_fetch_array($products_query); $products_count += $products['total']; $child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'"); if (tep_db_num_rows($child_categories_query)) { while ($child_categories = tep_db_fetch_array($child_categories_query)) { $products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive); } } return $products_count; } //// // Return true if the category has subcategories // TABLES: categories function tep_has_category_subcategories($category_id) { $child_category_query = tep_db_query("select count(*) as count from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'"); $child_category = tep_db_fetch_array($child_category_query); if ($child_category['count'] > 0) { return true; } else { return false; } } ..but in bm_categories only this without function "count" ?: <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ class bm_categories { var $code = 'bm_categories'; var $group = 'boxes'; var $title; var $description; var $sort_order; var $enabled = false; function __construct() { $this->title = MODULE_BOXES_CATEGORIES_TITLE; $this->description = MODULE_BOXES_CATEGORIES_DESCRIPTION; if ( defined('MODULE_BOXES_CATEGORIES_STATUS') ) { $this->sort_order = MODULE_BOXES_CATEGORIES_SORT_ORDER; $this->enabled = (MODULE_BOXES_CATEGORIES_STATUS == 'True'); $this->group = ((MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right'); } } function execute() { global $oscTemplate, $cPath; $OSCOM_CategoryTree = new category_tree (); $OSCOM_CategoryTree->setCategoryPath($cPath, '<strong>', '</strong>'); $OSCOM_CategoryTree->setSpacerString(' ', 1); $OSCOM_CategoryTree->setParentGroupString('<ul class="nav nav-pills nav-stacked">', '</ul>', true); $category_tree = $OSCOM_CategoryTree->getTree(); ob_start(); include('includes/modules/boxes/templates/categories.php'); $data = ob_get_clean(); $oscTemplate->addBlock($data, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_BOXES_CATEGORIES_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Categories Module', 'MODULE_BOXES_CATEGORIES_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_CATEGORIES_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_BOXES_CATEGORIES_STATUS', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'MODULE_BOXES_CATEGORIES_SORT_ORDER'); } } help me pls with missing function. Link to comment Share on other sites More sharing options...
♥JcMagpie Posted November 3, 2018 Share Posted November 3, 2018 You should find it in, includes/functions/general.php //// // Return the number of products in a category // TABLES: products, products_to_categories, categories function tep_count_products_in_category($category_id, $include_inactive = false) { $products_count = 0; if ($include_inactive == true) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'"); } else { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'"); } $products = tep_db_fetch_array($products_query); $products_count += $products['total']; $child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'"); if (tep_db_num_rows($child_categories_query)) { while ($child_categories = tep_db_fetch_array($child_categories_query)) { $products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive); } } return $products_count; } Link to comment Share on other sites More sharing options...
driven22 Posted November 4, 2018 Author Share Posted November 4, 2018 yes- i have it in general.php but in bm_categories.php no call to function count that's why counting products does not work in category box. It's should be ex.: Battery (10) Pencils (12) Pens (4) Now it's only: Battery Pencils Pens Link to comment Share on other sites More sharing options...
♥raiwa Posted November 4, 2018 Share Posted November 4, 2018 @driven22, You need to add it in includes/classes/category_tree.php to the categories name/link. Search for: $result .= $link_title . '</a>'; and replace with: $result .= $link_title . ' (' . tep_count_products_in_category($category_id, true) . ')</a>'; If you wish to include inactive products, keep the second parameter set to "true", otherwise change it to "false·. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
driven22 Posted November 4, 2018 Author Share Posted November 4, 2018 Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.