非常に簡単にRSSを取得し表示する 招待メールが送信されない
10 月 30

前回にも「新商品ブロックを作ろう」を書きましたが、
「特定のカテゴリーの新商品やお勧め商品を表示できるように設定できないか」
というお問い合わせがありましたので、カテゴリー指定バージョンを書きます。

基本的には前回の通りにブロックを作りましょう。
違うのは、LC_Page_FrontParts_Bloc_New.phpのロジックです。
以下がそのロジックです。

  1. function process() {
  2.  
  3. // 基本情報を渡す
  4. $objSiteInfo = new SC_SiteInfo();
  5. $this->arrInfo = $objSiteInfo->data;
  6.  
  7. $objQuery = new SC_Query();
  8.  
  9. $col    = " product_id, price02_min, price02_max, main_image, name";
  10. $from   = " vw_products_allclass ";
  11. $where  = " substring(product_flag,1,1) = ‘1′";
  12. $where .= " and del_flg = 0 ";
  13. $where .= " and category_id = カテゴリIDを指定";
  14. $order  = " rank";
  15.  
  16. $this->order=$objQuery->setorder($order);
  17. $arrNewProducts = $objQuery->select($col, $from, $where);
  18.  
  19. $this->arrNewProducts = $arrNewProducts;
  20.  
  21. $objSubView = new SC_SiteView();
  22. $objSubView->assignobj($this);
  23. $objSubView->display($this->tpl_mainpage);
  24. }

上記の「カテゴリIDを指定」の箇所に表示させたいカテゴリを指定。

もし、複数カテゴリを指定したい場合は、

  1. $col    = " DISTINCT product_id, price02_min, price02_max, main_image, name";
  2. $from   = " vw_products_allclass ";
  3. $where  = " substring(product_flag,1,1) = ‘1′";
  4. $where .= " and del_flg = 0 ";
  5. $where .= " and category_id IN (カンマ区切りでカテゴリIDを指定)";
  6. $order  = " rank";

と、DISTINCTをかまし、IN句で複数カテゴリを指定しましょう。

おすすめ商品も基本的には同じ。

このエントリをはてなブックマークに追加このエントリをdel.icio.usに追加このエントリをLivedoor Clipに追加このエントリをYahoo!ブックマークに追加このエントリをFC2ブックマークに追加このエントリをNifty Clipに追加このエントリをPOOKMARK. Airlinesに追加このエントリをBuzzurl(バザール)に追加このエントリをChoixに追加このエントリをnewsingに追加

written by sixbird \\ tags: , , ,

Leave a Reply