eCommerce迷走中

このドメインline.ne.jpを買いませんか

ec-cube

EC-CUBE 検索完全一致または完全一致+前方一致 空白ゼロ表示

投稿日:

src/Eccube/Repository/ProductRepository.php

151行に

// — 空検索チェック —
if (!empty(trim($searchData[‘name’] ?? ”))) {
$qb
->andWhere(‘p.name = :name_exact’)
->setParameter(‘name_exact’, $searchData[‘name’]);
} else {
$qb->andWhere(‘1 = 0’);
}
で完全一致

// — 空検索チェック —
if (!empty(trim($searchData[‘name’] ?? ”))) {
$qb
->andWhere(‘(p.name LIKE :name_head OR p.name = :name_exact)’)
->setParameter(‘name_head’, $searchData[‘name’].’%’)
->setParameter(‘name_exact’, $searchData[‘name’]);
} else {
$qb->andWhere(‘1 = 0’);
}
で完全一致+前方一致

// — 空検索チェック —
if (!empty(trim($searchData[‘name’] ?? ”))) {
$keyword = $searchData[‘name’];
$prefix = mb_substr($keyword, 0, 3);

$qb
    ->andWhere('(p.name = :name_exact OR SUBSTRING(p.name, 1, 3) = :name_prefix)')
    ->setParameter('name_exact', $keyword)
    ->setParameter('name_prefix', $prefix);

} else {
$qb->andWhere(‘1 = 0’);
}
で完全一致+前方3文字一致。

-ec-cube

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

関連記事

GoogleSearch-console

色々エラー報告を受けた。 まず、色々なパラメーター Price Brand 等が登録されない。 アドオンのJSON-LD Rich Snippetsというのを購入してみた。 https://marke …

EC-CUBE 3 のインストール

デフォルトルートの変更がやっかいとかなんで?こんなめんどくさいインストールシステムにしたんですかね?疑問です。 Xserver ならインストールメニューからデフォルトルートも指定できて安定感があります …