討論區: osCommerce FAQ (Thread #24152)

ベストセラーカスタマイズ (2009-10-08 20:47 by 匿名 #46302)

ベストセラーの30日での期間指定ですが、下記のように変更しましたが、
ベストセラーが表示されません。何か間違っていますでしょうか?

(変更前)
if (isset($current_category_id) && ($current_category_id > 0)) {
$subcategories_array = array();
tep_get_subcategories($subcategories_array, $new_products_category_id);
$where_str = " and (c.parent_id = '" . $new_products_category_id . "'";
for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
$where_str .= " or c.categories_id = '" . $subcategories_array[$i] . "'";
}
$where_str .= ")";
$best_sellers_query = tep_db_query("select distinct p.products_id,p.products_image,pd.products_name,pd.products_description ,p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id , " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id " . $where_str . " order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
} else {
$best_sellers_query = tep_db_query("select distinct p.products_id,p.products_image,pd.products_name,pd.products_description ,p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id , " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
}

if (tep_db_num_rows($best_sellers_query) >= MIN_DISPLAY_BESTSELLERS) {
?>


(変更後)

if (isset($current_category_id) && ($current_category_id > 0)) {
$subcategories_array = array();
tep_get_subcategories($subcategories_array, $new_products_category_id);
$where_str = " and (c.parent_id = '" . $new_products_category_id . "'";
for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
$where_str .= " or c.categories_id = '" . $subcategories_array[$i] . "'";
}
$where_str .= ")";
$best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, sum(op.products_quantity) as products_quantity from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op where op.products_id = p.products_id and op.orders_id = o.orders_id and o.date_purchased >= DATE_SUB(now(), INTERVAL 30 DAY) and p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . $current_category_id . "' in (c.categories_id, c.parent_id) group by op.products_id order by products_quantity desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
} else {
$best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, sum(op.products_quantity) as products_quantity from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op where op.products_id = p.products_id and op.orders_id = o.orders_id and o.date_purchased >= DATE_SUB(now(), INTERVAL 30 DAY) and p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' group by op.products_id order by products_quantity desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
}






回覆 #46302×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入