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句で複数カテゴリを指定しましょう。

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

written by sixbird \\ tags: , , ,

8 月 13

最近はECサイトに人の存在感を与え、そして安心感を与えるためにブログも運営することが多くなった。

そこで、ECサイトにそのブログのRSS情報を非常に簡単に表示する方法。
ただしPHP5が条件。
なぜなら、simplexml_load_fileを使用するから。

EC-CUBEを利用、新規ブロックを作成した場合の方法。

/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Rss.php

  1. function process() {
  2.  
  3. $memore_rss =simplexml_load_file(‘http://memo.6-bird.net/feed/’);
  4. $this->memore_rss = $memore_rss;
  5.  
  6. $objSubView = new SC_SiteView();
  7. $objSubView->assignobj($this);
  8. $objSubView->display($this->tpl_mainpage);
  9. }

/user_data/packages/memore/bloc/rss.tpl

  1. <ol>
  2. {foreach from=$memore_rss->channel->item item="datum" key="key" name="memore_rss"}
  3.     <li><!–{$datum->pubDate|date_format:"%Y-%m-%d"}–> <a href="<!–{$datum->link}–>"><!–{$datum->title}–></a></li>
  4. {/foreach}
  5. </ol>

これで、ブログの記事タイトルにリンクがはられ、ズラーッと表示される。

written by sixbird \\ tags: ,