* new_products.php module * * @package modules * @copyright Copyright 2003-2008 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @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 . ")"; } }
$where_cat = "AND p.products_id = p2c.products_id\n AND c.categories_id = " . (int) $current_category_id . "\n AND p2c.categories_id = " . (int) $current_category_id . " "; } else { $where_cat = "AND p.master_categories_id = " . (int) $current_category_id . " "; } } $expected_query = "SELECT DISTINCT p.products_id, pd.products_name, pd.products_description, p.products_image, GREATEST(p.products_date_added, IFNULL(p.products_last_modified, 0)) AS products_date, p.products_date_available as date_expected, p.products_price_sorter as price, p.products_tax_class_id, p.products_quantity, p.products_model, p.products_weight, p.manufacturers_id, m.manufacturers_name, r.reviews_rating\n FROM " . TABLE_PRODUCTS . " p\n LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id = p.products_id)\n LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id)\n LEFT JOIN " . TABLE_REVIEWS . " r ON (p.products_id = r.products_id)\n " . $from_cat . "\n WHERE to_days(products_date_available) >= to_days(now())\n AND p.products_status = 1\n AND pd.language_id = " . (int) $_SESSION['languages_id'] . "\n " . $where_cat . "\n " . $display_limit . "\n ORDER BY " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . $limit; zen_rss_products($expected_query, $random); break; case "new_products_random": $random = true; $rss->rssFeedCahcheSet(false); $limit = " LIMIT " . MAX_RANDOM_SELECT_NEW; case "new_products": $disp_order_default = PRODUCT_NEW_LIST_SORT_DEFAULT; require DIR_WS_MODULES . zen_get_module_directory(FILENAME_LISTING_DISPLAY_ORDER); $where_days = zen_get_new_date_range(); case "products": default: $where_cat = $from_cat = ""; if (isset($current_category_id) && $current_category_id > 0) { if (RSS_PRODUCTS_CATEGORIES == 'all') { $from_cat = ", " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c "; $where_cat = "AND p.products_id = p2c.products_id\n AND c.categories_id = " . (int) $current_category_id . "\n AND p2c.categories_id = " . (int) $current_category_id . " "; } else { $where_cat = "AND p.master_categories_id = " . (int) $current_category_id . " "; } } $where_prod = ''; if (isset($_GET['products_id'])) { $where_prod = " AND p.products_id=" . (int) $_GET['products_id']; $limit = " LIMIT 1";