質問 > フロント機能 > 商品検索項目の追加について |
フロント機能
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
nksm |
投稿日時: 2014/8/6 12:50
対応状況: −−−
|
半人前 登録日: 2012/4/25 居住地: 投稿: 24 |
商品検索項目の追加について EC-CUBE 2.12.2
DBサーバー PostgreSQL 8.1.23 PHP 5.3.28 現在、構築中のサイトにて各商品に商品重量を設定し、 商品検索に重量別(○gまでの商品、○g〜○gまでの商品)での検索を 実現しようとしています。 2.11にて運用していた際はdata/class/pages/products/LC_Page_Products_List.phpの修正で 同様の仕様を実現出来たのですが、今回同じ改修を加え、 検索結果の表示までは確認出来たのですが、 検索結果数の表示が上手くいきません。(「全○商品中 ○〜○件表示」の部分) 改修した箇所は下記の通りです。 data/class/SC_Product.php function findProductIdsOrder(&$objQuery, $arrVal = array()) { $table = <<< __EOS__ dtb_products AS alldtl ↓ function findProductIdsOrder(&$objQuery, $arrVal = array()) { $table = <<< __EOS__ dtb_products AS alldtl JOIN dtb_products_class AS T1 ON alldtl.product_id = T1.product_id data/class/pages/products/LC_Page_Products_List.php //表示条件の取得 に 'deliv_fee_min' => $this->arrForm['deliv_fee_min'], 'deliv_fee_max' => $this->arrForm['deliv_fee_max'] を追加 function lfGetSearchCondition を function lfGetSearchCondition($arrSearchData) { $searchCondition = array( 'where' => '', 'arrval' => array(), 'where_category' => '', 'arrvalCategory' => array() ); // カテゴリからのWHERE文字列取得 if ($arrSearchData['category_id'] != 0) { list($searchCondition['where_category'], $searchCondition['arrvalCategory']) = SC_Helper_DB_Ex::sfGetCatWhere($arrSearchData['category_id']); } // ▼対象商品IDの抽出 // 商品検索条件の作成(未削除、表示) $searchCondition['where'] = 'alldtl.del_flg = 0 AND alldtl.status = 1 '; if (strlen($searchCondition['where_category']) >= 1) { $searchCondition['where'] .= ' AND EXISTS (SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ' AND product_id = alldtl.product_id)'; $searchCondition['arrval'] = array_merge($searchCondition['arrval'], $searchCondition['arrvalCategory']); } // 商品名をwhere文に $name = $arrSearchData['name']; $name = str_replace(',', '', $name); // 全角スペースを半角スペースに変換 $name = str_replace(' ', ' ', $name); // スペースでキーワードを分割 $names = preg_split('/ +/', $name); // 分割したキーワードを一つずつwhere文に追加 foreach ($names as $val) { if (strlen($val) > 0) { $searchCondition['where'] .= ' AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) '; $searchCondition['arrval'][] = "%$val%"; $searchCondition['arrval'][] = "%$val%"; } } // メーカーらのWHERE文字列取得 if ($arrSearchData['maker_id']) { $searchCondition['where'] .= ' AND alldtl.maker_id = ? '; $searchCondition['arrval'][] = $arrSearchData['maker_id']; } $searchCondition['where_for_count'] = $searchCondition['where']; // 重量検索 if ($arrSearchData['deliv_fee_min'] != 0 && $arrSearchData['deliv_fee_max'] != 0) { $searchCondition['where'] .= ' AND T1.deliv_fee >= ? AND T1.deliv_fee <= ?'; $searchCondition['arrval'][] = $arrSearchData['deliv_fee_min']; $searchCondition['arrval'][] = $arrSearchData['deliv_fee_max']; } elseif ($arrSearchData['deliv_fee_min'] != 0 && $arrSearchData['deliv_fee_max'] == 0) { $searchCondition['where'] .= ' AND T1.deliv_fee >= ?'; $searchCondition['arrval'][] = $arrSearchData['deliv_fee_min']; } elseif ($arrSearchData['deliv_fee_min'] == 0 && $arrSearchData["deliv_fee_max"] != 0) { $searchCondition['where'] .= ' AND T1.deliv_fee <= ?'; $searchCondition['arrval'][] = $arrSearchData['deliv_fee_max']; } // 在庫無し商品の非表示 if (NOSTOCK_HIDDEN) { $searchCondition['where'] .= ' AND EXISTS(SELECT * FROM dtb_products_class WHERE product_id = alldtl.product_id AND del_flg = 0 AND (stock >= 1 OR stock_unlimited = 1))'; $searchCondition['where_for_count'] .= ' AND EXISTS(SELECT * FROM dtb_products_class WHERE product_id = alldtl.product_id AND del_flg = 0 AND (stock >= 1 OR stock_unlimited = 1))'; } return $searchCondition; } に変更です。 カテゴリー及び商品重量のみで検索した場合には検索結果と結果数がマッチするのですが、 キーワードと商品重量を入力して検索するとキーワードのみで検索した場合の結果数が返っている状態です。 何かお気付きの点がありましたらご教示頂けますと幸いです。 |
フラット表示 | 前のトピック | 次のトピック |
題名 | 投稿者 | 日時 |
---|---|---|
» 商品検索項目の追加について | nksm | 2014/8/6 12:50 |
Re: 商品検索項目の追加について | yuh | 2014/8/6 13:19 |
Re: 商品検索項目の追加について | nksm | 2014/8/6 14:07 |
Re: 商品検索項目の追加について | yuh | 2014/8/6 14:19 |
Re: 商品検索項目の追加について | nksm | 2014/8/6 17:02 |