[Tep-j-general] Re: 複数カテゴリー登録商品の「○月の新着商品」への表示

Back to archive index

Kobayashi yuki-****@kmail*****
2006年 5月 12日 (金) 10:12:39 JST


自己レスです。
下記コードのように、distinctを加えることで解決しました。

   if ( (!isset($new_products_category_id)) ||
($new_products_category_id == '0') ) {
     $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, 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_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where c.categories_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and products_status = '1' order by p.products_last_modified DESC limit " . MAX_DISPLAY_NEW_PRODUCTS);
   } else {
     $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, 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_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where c.categories_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1' order by p.products_last_modified DESC limit " . MAX_DISPLAY_NEW_PRODUCTS);
   }

-- 
小林



Tep-j-general メーリングリストの案内
Back to archive index