0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

B2C Commerceで商品検索を実装

Last updated at Posted at 2023-10-31

サイト全体で商品を検索

RefArch標準のテンプレートを使う。
以下を、検索フォームに実装。

cartridges/app_storefront_base/cartridge/templates/default/components/header/pageHeader.isml
<isinclude template="components/header/search" />

検索時のリクエストが以下のようになっている

Search-Show?&q=スーツ&lang=ja_JP

カテゴリー内で商品を検索

RefArchでは実装されていないので、以下のようにカテゴリー付きでリクエストを送るように実装。

Search-Show?cgid=newarrivals-mens&q=スーツ&lang=ja_JP

そのため、リクエストの内容からカテゴリーを取り出し、hidden fieldに含めるという方針で実装した。

cartridges/app_storefront_base/cartridge/templates/default/components/header/search.isml
<isscript>
    var selectedCategory = request.httpParameterMap.cgid.stringValue;
</isscript>
<input type="hidden" value="${selectedCategory}" name="cgid">

検索対象

ProductSearchModelを使用して、注文可能商品のみを表示している。

検索条件の設定

マーチャントツール > 検索 > 検索インデックス > 商品インデックス - 全般

スクリーンショット 2023-11-14 11.02.22.png

公式サイト

検索可能な属性を指定することも可能となる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?