function zen_get_categories_products_list($categories_id, $include_deactivated = false, $include_child = true)
{
    global $db;
    global $categories_products_id_list;
    if ($include_deactivated) {
        $products = $db->Execute("select p.products_id\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) $categories_id . "'");
    } else {
        $products = $db->Execute("select p.products_id\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) $categories_id . "'");
    }
    while (!$products->EOF) {
        // categories_products_id_list keeps resetting when category changes ...
        //      echo 'Products ID: ' . $products->fields['products_id'] . '<br>';
        $categories_products_id_list[] = $products->fields['products_id'];
        $products->MoveNext();
    }
    if ($include_child) {
        $childs = $db->Execute("select categories_id from " . TABLE_CATEGORIES . "\r\n                              where parent_id = '" . (int) $categories_id . "'");
        if ($childs->RecordCount() > 0) {
            while (!$childs->EOF) {
                zen_get_categories_products_list($childs->fields['categories_id'], $include_deactivated);
                $childs->MoveNext();
            }
        }
    }
    $products_id_listing = $categories_products_id_list;
    return $products_id_listing;
}
Ejemplo n.º 2
0
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: new_products.php 8730 2008-06-28 01:31:22Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
}
// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$new_products_query = '';
$display_limit = zen_get_new_date_range();
if ($manufacturers_id > 0 && $_GET['filter_id'] == 0 || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0 || (!isset($new_products_category_id) || $new_products_category_id == '0')) {
    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,\n                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id\n                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd\n                           where p.products_id = pd.products_id\n                           and pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n                           and   p.products_status = 1 " . $display_limit;
} else {
    // get all products and cPaths in this subcat tree
    $productsInCategory = zen_get_categories_products_list($manufacturers_id > 0 && $_GET['filter_id'] > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath, false, true, 0, $display_limit);
    if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        // build products-list string to insert into SQL query
        foreach ($productsInCategory as $key => $value) {
            $list_of_products .= $key . ', ';
        }
        $list_of_products = substr($list_of_products, 0, -2);
        // remove trailing comma
        $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,\n                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id\n                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd\n                           where p.products_id = pd.products_id\n                           and pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n                           and p.products_status = 1\n                           and p.products_id in (" . $list_of_products . ")";
    }
}
if ($new_products_query != '') {
    $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS);
}
$row = 0;
$col = 0;
function zen_get_categories_products_list($categories_id, $include_deactivated = false, $include_child = true, $parent_category = '0', $display_limit = '')
{
    global $db;
    global $categories_products_id_list;
    $childCatID = str_replace('_', '', substr($categories_id, strrpos($categories_id, '_')));
    $current_cPath = ($parent_category != '0' ? $parent_category . '_' : '') . $categories_id;
    $sql = "select p.products_id\n            from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n            where p.products_id = p2c.products_id\n            and p2c.categories_id = '" . (int) $childCatID . "'" . ($include_deactivated ? " and p.products_status = 1" : "") . $display_limit;
    $products = $db->Execute($sql);
    while (!$products->EOF) {
        $categories_products_id_list[$products->fields['products_id']] = $current_cPath;
        $products->MoveNext();
    }
    if ($include_child) {
        $sql = "select categories_id from " . TABLE_CATEGORIES . "\n              where parent_id = '" . (int) $childCatID . "'";
        $childs = $db->Execute($sql);
        if ($childs->RecordCount() > 0) {
            while (!$childs->EOF) {
                zen_get_categories_products_list($childs->fields['categories_id'], $include_deactivated, $include_child, $current_cPath, $display_limit);
                $childs->MoveNext();
            }
        }
    }
    return $categories_products_id_list;
}
Ejemplo n.º 4
0
                 if ($data !== false) {
                     foreach ($data as $key => $d) {
                         $data[$key] = mb_convert_encoding($d, MODULE_PRODUCT_CSV_EXPORT_CHARACTER, MODULE_PRODUCT_CSV_INTERNAL_CHARACTER);
                         $data[$key] = str_replace("\r\n", "\n", $data[$key]);
                     }
                     File_CSV::write($tempfile, $data, $conf);
                 }
             }
         }
     }
     break;
 case 3:
     $prefix = 'options_';
     // get products_id
     $categories_products_id_list = array();
     $products_ids = zen_get_categories_products_list($_POST['category_id'], true, true);
     $products_ids = array_unique($products_ids);
     // write line
     foreach ($products_ids as $val) {
         $attributes_ids = zen_get_attributes($val);
         foreach ($attributes_ids as $id) {
             $data = $ProductCSV->getExportDataOption($id, $format);
             if (count($data) == 0) {
                 continue;
             }
             foreach ($data as $key => $d) {
                 $data[$key] = mb_convert_encoding($d, MODULE_PRODUCT_CSV_EXPORT_CHARACTER, MODULE_PRODUCT_CSV_INTERNAL_CHARACTER);
                 $data[$key] = str_replace("\r\n", "\n", $data[$key]);
             }
             File_CSV::write($tempfile, $data, $conf);
         }