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,67 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Elastic Search Base for Magento 2
*/
namespace Amasty\ElasticSearch\Model\Indexer\Data\External;
use Amasty\ElasticSearch\Api\Data\Indexer\Data\DataMapperInterface;
use Amasty\ElasticSearch\Model\Indexer\Structure\EntityBuilder\External\Finder;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
class FinderDataMapper implements DataMapperInterface
{
/**
* @var \Magento\Eav\Model\ResourceModel\Entity\Attribute
*/
private $eavAttribute;
/**
* @var Finder
*/
private $externalBuilder;
public function __construct(
\Magento\Eav\Model\ResourceModel\Entity\Attribute $eavAttribute,
Finder $externalBuilder
) {
$this->eavAttribute = $eavAttribute;
$this->externalBuilder = $externalBuilder;
}
/**
* @param array $documentData
* @param int $storeId
* @param array $context
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function map(array $documentData, $storeId, array $context = [])
{
$documents = [];
$externalAttributeIds = [];
foreach (array_keys($this->externalBuilder->getExtraValueFields()) as $attributeCode) {
$externalAttributeIds[$attributeCode . '_value']
= $this->eavAttribute->getIdByCode(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode);
}
foreach ($documentData as $productId => $indexData) {
foreach ($externalAttributeIds as $filterName => $attributeId) {
if (isset($indexData[$attributeId])) {
if (is_array($indexData[$attributeId])) {
$value = isset($indexData[$attributeId][$productId])
? $indexData[$attributeId][$productId] : '';
} else {
$value = $indexData[$attributeId];
}
$documents[$productId][$filterName] = $value;
}
}
}
return $documents;
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Elastic Search Base for Magento 2
*/
namespace Amasty\ElasticSearch\Model\Indexer\Data\External;
use Amasty\ElasticSearch\Api\Data\Indexer\Data\DataMapperInterface;
use Amasty\ElasticSearch\Api\RelevanceRuleRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;
class RelevanceBoostDataMapper implements DataMapperInterface
{
public const DEFAULT_RELEVANCE = 1.;
public const ATTRIBUTE_NAME = 'amasty_product_relevance';
/**
* @var RelevanceRuleRepositoryInterface
*/
private $relevanceRuleRepository;
/**
* @var StoreManagerInterface
*/
private $storeManager;
public function __construct(
RelevanceRuleRepositoryInterface $relevanceRuleRepository,
StoreManagerInterface $storeManager
) {
$this->relevanceRuleRepository = $relevanceRuleRepository;
$this->storeManager = $storeManager;
}
public function map(array $indexData, $storeId, array $context = []): array
{
$websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
$productIds = array_keys($indexData);
$productBoostData = $this->relevanceRuleRepository->getProductBoostMultipliers($productIds, (int) $websiteId);
$indexBoostData = [];
foreach ($indexData as $productId => $productData) {
$indexBoostData[$productId] = [
self::ATTRIBUTE_NAME => $productBoostData[$productId] ?? self::DEFAULT_RELEVANCE
];
}
return $indexBoostData;
}
}