File Location: manager\includes\modules\category_product_listing.php
File contents:
if (zen_get_products_to_categories ($categories->fields[' categories_id '), true, ' products_active ') = = ' true ') {
Echo ' '. Zen_image (dir_ws_images. ' Icon_yellow_on.gif ', image_icon_linked);
}
Function Location: Background \includes\functions\general.php
Function Contents:
//////////////////////////////////////////////////////////
function zen_get_products_to_categories ($category _id, $include _inactive = False, $counts _what = ' products ') {
Global $db;
$products _count = 0;
if ($include _inactive = = true) {
switch ($counts _what) {
Case (' products '):
$cat _products_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. "‘";
break;
Case (' products_active '):
$cat _products_query = "Select p.products_id
from ". Table_products. "P,". Table_products_to_categories. "P2c
where p.products_id = p2c.products_id
and p2c.categories_id = ' ". (int) $category _id. "'";
break;
}
} else {
switch ($counts _what) {
Case [' Products ']:
$cat _products_query = "SELECT count (*) as Total
fr Om ". 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. "‘";
break;
Case (' products_active '):
$cat _products_query = "Select p.products_id
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. "‘";
break;
}
}
$cat _products = $db->execute ($cat _products_query);
Switch ($counts _what) {
Case (' Products '):
$cat _products_count + = $cat _products->fields[' total ';
Break
Case (' products_active '):
while (! $cat _products->eof) {
if (zen_get_product_is_linked ($cat _products->fields[' products_id ') = = = ' true ') {
return $products _linked = ' true ';
}
$cat _products->movenext ();
}
Break
}
$cat _child_categories_query = "Select categories_id
From ". Table_categories. "
where parent_id = ' ". (int) $category _id. "‘";
$cat _child_categories = $db->execute ($cat _child_categories_query);
if ($cat _child_categories->recordcount () > 0) {
while (! $cat _child_categories->eof) {
Switch ($counts _what) {
Case (' Products '):
$cat _products_count + = zen_get_products_to_categories ($cat _child_categories->fields[' categories_id '), $include _inactive);
Break
Case (' products_active '):
if (zen_get_products_to_categories ($cat _child_categories->fields[' categories_id '), true, ' products_active ') = = ' True ') {
return $products _linked = ' true ';
}
Break
}
$cat _child_categories->movenext ();
}
}
Switch ($counts _what) {
Case (' Products '):
return $cat _products_count;
Break
Case (' products_active '):
return $products _linked;
Break
}
}
Zencart Background Catalog Products Yellow Icon_yellow_on.gif Solution