function zen_count_products_in_category($category_id, $include_inactive = false)
{
    global $db;
    $products_count = 0;
    if ($include_inactive == true) {
        $products_query = "select count(*) as total\r\n                         from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\r\n                         where p.products_id = p2c.products_id\r\n                         and p2c.categories_id = '" . (int) $category_id . "'";
    } else {
        $products_query = "select count(*) as total\r\n                         from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\r\n                         where p.products_id = p2c.products_id\r\n                         and p.products_status = '1'\r\n                         and p2c.categories_id = '" . (int) $category_id . "'";
    }
    $products = $db->Execute($products_query);
    $products_count += $products->fields['total'];
    $child_categories_query = "select categories_id\r\n                               from " . TABLE_CATEGORIES . "\r\n                               where parent_id = '" . (int) $category_id . "'";
    $child_categories = $db->Execute($child_categories_query);
    if ($child_categories->RecordCount() > 0) {
        while (!$child_categories->EOF) {
            $products_count += zen_count_products_in_category($child_categories->fields['categories_id'], $include_inactive);
            $child_categories->MoveNext();
        }
    }
    return $products_count;
}
function zen_count_products_in_category($category_id, $include_inactive = false)
{
    global $gBitDb, $gBitProduct;
    $products_count = 0;
    $selectSql = '';
    $joinSql = '';
    $whereSql = '';
    $gBitProduct->getGatekeeperSql($selectSql, $joinSql, $whereSql);
    if ($include_inactive == true) {
        $whereSql .= " and p.`products_status` = '1' ";
    }
    $products_query = "select count(*) as `total`\n                         from " . TABLE_PRODUCTS . " p\n\t\t\t\t\t\t  INNER JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON (p.`products_id` = p2c.`products_id`) {$joinSql}\n                         where p2c.`categories_id` = ? {$whereSql}";
    $products = $gBitDb->query($products_query, array($category_id));
    $products_count += $products->fields['total'];
    $child_categories_query = "select `categories_id`\n                               from " . TABLE_CATEGORIES . "\n                               where `parent_id` = '" . (int) $category_id . "'";
    $child_categories = $gBitDb->Execute($child_categories_query);
    if ($child_categories->RecordCount() > 0) {
        while (!$child_categories->EOF) {
            $products_count += zen_count_products_in_category($child_categories->fields['categories_id'], $include_inactive);
            $child_categories->MoveNext();
        }
    }
    return $products_count;
}
Example #3
0
}
$displayTypes = substr($display, 0, strlen($display) - (is_numeric(substr($display, -1, 1)) ? 2 : 0));
if ($current_page != 'advanced_search_result') {
    $listTypes = isset($listTypes) ? $listTypes : zen_get_categories_listTypes($current_category_id);
}
//echo $listing_sql;
$show_submit = zen_run_normal();
$listing_split = new splitPageResults($listing_sql, isset($_GET['pagesize']) ? $_GET['pagesize'] : MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
$zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
$how_many = 0;
$zc_col_count_description = 0;
$lc_align = '';
$list_box_contents = array();
//echo $listing_split->sql_query;
//print_r(explode(' ',zen_products_id_in_category($current_category_id)));
if (zen_count_products_in_category($current_category_id) > 0) {
    $listing = $db->Execute($listing_split->sql_query);
    $row = 0;
    while (!$listing->EOF) {
        if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
            $list_box_contents[$row]['products_image'] = '';
        } else {
            $list_box_contents[$row]['products_image'] = $listing->fields['products_image'];
        }
        $list_box_contents[$row]['products_name'] = $listing->fields['products_name'];
        $list_box_contents[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), 100);
        $list_box_contents[$row]['products_price'] = zen_get_products_base_price($listing->fields['products_id']);
        $list_box_contents[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($listing->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id']));
        $list_box_contents[$row]['products_status'] = $listing->fields['products_status'];
        if ($listing->fields['product_is_always_free_shipping'] == 0) {
            $list_box_contents[$row]['product_is_always_free_shipping'] = '';
Example #4
0
 function zen_show_category($counter, $ii)
 {
     global $cPath_array;
     $this->categories_string = "";
     for ($i = 0; $i < $this->tree[$counter]['level']; $i++) {
         if ($this->tree[$counter]['parent'] != 0) {
             $this->categories_string .= CATEGORIES_SUBCATEGORIES_INDENT;
         }
     }
     if ($this->tree[$counter]['parent'] == 0) {
         $cPath_new = 'cPath=' . $counter;
         $this->box_categories_array[$ii]['top'] = 'true';
     } else {
         $this->box_categories_array[$ii]['top'] = 'false';
         $cPath_new = 'cPath=' . $this->tree[$counter]['path'];
         $this->categories_string .= CATEGORIES_SEPARATOR_SUBS;
     }
     $this->box_categories_array[$ii]['path'] = $cPath_new;
     if (isset($cPath_array) && in_array($counter, $cPath_array)) {
         $this->box_categories_array[$ii]['current'] = true;
     } else {
         $this->box_categories_array[$ii]['current'] = false;
     }
     // display category name
     $this->box_categories_array[$ii]['name'] = $this->categories_string . $this->tree[$counter]['name'];
     // make category image available in case needed
     $this->box_categories_array[$ii]['image'] = $this->tree[$counter]['image'];
     if (zen_has_category_subcategories($counter)) {
         $this->box_categories_array[$ii]['has_sub_cat'] = true;
     } else {
         $this->box_categories_array[$ii]['has_sub_cat'] = false;
     }
     $this->box_categories_array[$ii]['categories_id'] = $counter;
     $this->box_categories_array[$ii]['parent_id'] = $this->tree[$counter]['parent'];
     if (SHOW_COUNTS == 'true') {
         $products_in_category = zen_count_products_in_category($counter);
         if ($products_in_category > 0) {
             $this->box_categories_array[$ii]['count'] = $products_in_category;
         } else {
             $this->box_categories_array[$ii]['count'] = 0;
         }
     }
     if ($this->tree[$counter]['next_id'] != false) {
         $ii++;
         $this->zen_show_category($this->tree[$counter]['next_id'], $ii);
     }
     return $this->box_categories_array;
 }
Example #5
0
function zen_rss_category_tree($id_parent = 0, $str_cPath = '', $limit = 32767)
{
    global $db, $rss, $additionalURL;
    if ($limit < 0) {
        return;
    }
    $categories = $db->Execute("SELECT c.categories_id, c.parent_id, GREATEST(c.date_added, IFNULL(c.last_modified, 0)) AS categories_date, c.categories_image, cd.categories_name, cd.categories_description\n                       FROM " . TABLE_CATEGORIES . " c\n                         LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id\n                       WHERE c.parent_id = " . (int) $id_parent . "\n                         AND cd.language_id = " . (int) $_SESSION['languages_id'] . "\n                         AND c.categories_status = 1\n                       ORDER BY c.sort_order, cd.categories_name", '', false, 150);
    if ($categories->RecordCount() == 0) {
        return;
    }
    while (!$categories->EOF && $limit > 0) {
        $new_str_cPath = zen_not_null($str_cPath) ? $str_cPath . '_' . $categories->fields['categories_id'] : $categories->fields['categories_id'];
        $products_in_category = zen_count_products_in_category($categories->fields['categories_id']);
        if (CATEGORIES_COUNT_ZERO == '1' && $products_in_category == 0 or $products_in_category >= 1) {
            $limit--;
            $link = zen_href_link(FILENAME_DEFAULT, 'cPath=' . $new_str_cPath . $additionalURL, 'NONSSL', false);
            $rss->rss_feed_item($categories->fields['categories_name'], $link, array('url' => $link, 'PermaLink' => true), date('r', strtotime($categories->fields['categories_date'])), $categories->fields['categories_description'], $categories->fields['categories_image'], false, RSS_AUTHOR == '' ? STORE_OWNER_EMAIL_ADDRESS . " <" . STORE_OWNER . ">" : RSS_AUTHOR);
        }
        if (zen_has_category_subcategories($categories->fields['categories_id'])) {
            zen_rss_category_tree($categories->fields['categories_id'], $new_str_cPath, $limit);
        }
        $categories->MoveNext();
    }
}
 function buildBranch($parent_id, $level = 0, $submenu = false)
 {
     if ($level == 0) {
         $result = $this->parent_group_start_string_noif;
     } else {
         $result = sprintf($this->parent_group_start_string, '');
     }
     if (isset($this->data[$parent_id])) {
         if ($this->i_display > 0) {
             $i = 0;
             while (list($category_id, $category) = each($this->data[$parent_id]) and $i <= $this->max_display) {
                 $category_link = $category_id;
                 if (isset($this->data[$category_id])) {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_two, $submenu == true ? ' class="b_top"' : '');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_two, '');
                     }
                 } else {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_two, ' class="b_top"');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_two, '');
                     }
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_start_string;
                 }
                 if ($level == 0) {
                     $result .= $this->root_start_string;
                 }
                 if ($i == $this->max_display) {
                     $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . zen_get_categories_parent_id($category_link)) . '">';
                     $result .= 'All ' . zen_get_categories_parent_name($category_id);
                     $result .= '</a>';
                 } else {
                     $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">';
                     $result .= $category['name'];
                     if (zen_count_products_in_category($category_id)) {
                         $result .= '&nbsp;(' . zen_count_products_in_category($category_id) . ')';
                     }
                     $result .= '</a>';
                 }
                 if ($level == 0) {
                     $result .= $this->root_end_string;
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_end_string;
                 }
                 if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) {
                     $this->i_display++;
                     $result .= $this->buildBranch($category_id, $level + 1, $submenu);
                 }
                 $result .= $this->child_end_string;
                 $i++;
             }
         } else {
             while (list($category_id, $category) = each($this->data[$parent_id])) {
                 $category_link = $category_id;
                 if (isset($this->data[$category_id])) {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_string, $submenu == true ? ' class="b_top"' : '');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_string, '');
                     }
                 } else {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_string, ' class="b_top"');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_string, '');
                     }
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_start_string;
                 }
                 if ($level == 0) {
                     $result .= $this->root_start_string;
                 }
                 $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">';
                 $result .= substr($category['name'], 0, 25);
                 if ($level == 0) {
                     if (zen_has_category_subcategories($category_id)) {
                         $result .= '<!--[if IE 7]><!--></a><!--<![endif]-->' . "\n";
                     } else {
                         $result .= '</a>' . "\n";
                     }
                     $result .= $this->root_end_string;
                 } else {
                     $result .= '</a>';
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_end_string;
                 }
                 if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) {
                     $this->i_display++;
                     $result .= $this->buildBranch($category_id, $level + 1, $submenu);
                 }
                 $result .= $this->child_end_string;
             }
         }
     }
     if ($level == 1) {
         $b_top = 0;
     }
     if ($level == 0) {
         $result .= $this->parent_group_end_string_noif;
     } else {
         $result .= $this->parent_group_end_string;
     }
     return $result;
 }