ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,17 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Elastic Search Base for Magento 2
*/
namespace Amasty\ElasticSearch\Model\Search\GetRequestQuery\ServicePreprocessor;
interface PreprocessorInterface
{
/**
* @param string $query
* @return string
*/
public function process($query);
}
@@ -0,0 +1,53 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Elastic Search Base for Magento 2
*/
namespace Amasty\ElasticSearch\Model\Search\GetRequestQuery\ServicePreprocessor;
use Amasty\ElasticSearch\Api\StopWordRepositoryInterface;
class Stopwords implements PreprocessorInterface
{
/**
* @var StopWordRepositoryInterface
*/
private $stopWordRepository;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
StopWordRepositoryInterface $stopWordRepository
) {
$this->stopWordRepository = $stopWordRepository;
$this->storeManager = $storeManager;
}
/**
* @param string $query
* @return string
*/
public function process($query)
{
$storeId = $this->storeManager->getStore()->getId();
$stopWords = $this->stopWordRepository->getArrayListByStoreId($storeId);
$origQuery = $query;
// remove stop words from query
$query = explode(' ', $query);
$query = implode(' ', array_diff($query, $stopWords));
$query = trim($query);
if (!$query) {
$query = $origQuery;//return query if query is only from stop words
}
return $query;
}
}
@@ -0,0 +1,57 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Elastic Search Base for Magento 2
*/
namespace Amasty\ElasticSearch\Model\Search\GetRequestQuery\ServicePreprocessor;
use Amasty\ElasticSearch\Api\SynonymRepositoryInterface;
class Synonyms implements PreprocessorInterface
{
public const SYNONYM_DELEMITER = '$';
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var SynonymRepositoryInterface
*/
private $synonymRepository;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
SynonymRepositoryInterface $synonymRepository
) {
$this->storeManager = $storeManager;
$this->synonymRepository = $synonymRepository;
}
/**
* @param string $query
* @return string
*/
public function process($query)
{
if (!$query) {
return $query;
}
$storeId = $this->storeManager->getStore()->getId();
$synonymsArray = $this->synonymRepository->getSynonymsByQuery($query, $storeId);
if (!empty($synonymsArray)) {
$synonyms = [];
foreach ($synonymsArray as $synonymPart) {
$synonyms [] = implode(self::SYNONYM_DELEMITER, $synonymPart);
}
$query = implode(' ', $synonyms);
}
return $query;
}
}