Zencart Background Catalog Products Yellow Icon_yellow_on.gif Solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.