ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Elastic Search Base for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\ElasticSearch\Model\ResourceModel\Synonym;
|
||||
|
||||
use Amasty\ElasticSearch\Api\Data\SynonymInterface;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_idFieldName = 'synonym_id';
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Amasty\ElasticSearch\Model\Synonym::class,
|
||||
\Amasty\ElasticSearch\Model\ResourceModel\Synonym::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
*/
|
||||
public function deleteByIds(array $ids)
|
||||
{
|
||||
$this->getConnection()->delete(
|
||||
$this->getMainTable(),
|
||||
['synonym_id IN(?)' => implode(',', $ids)]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $searchString
|
||||
* @return $this
|
||||
*/
|
||||
public function addSearchStringFilter($searchString)
|
||||
{
|
||||
// phpcs:ignore
|
||||
$searchString = addslashes($searchString);
|
||||
$this->getSelect()
|
||||
->where(
|
||||
SynonymInterface::TERM . ' ?',
|
||||
new \Zend_Db_Expr('REGEXP \'' . $searchString . '\'')
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add filter by store
|
||||
*
|
||||
* @param null $store
|
||||
* @return $this
|
||||
*/
|
||||
public function addStoreFilter($store = null)
|
||||
{
|
||||
$storeId = $store;
|
||||
|
||||
if ($store instanceof Store) {
|
||||
$storeId = $store->getId();
|
||||
}
|
||||
|
||||
$this->getSelect()->where('store_id = ?', $storeId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Elastic Search Base for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\ElasticSearch\Model\ResourceModel\Synonym;
|
||||
|
||||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
|
||||
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
|
||||
use Magento\Framework\Event\ManagerInterface as EventManager;
|
||||
use Amasty\ElasticSearch\Api\Data\SynonymInterface;
|
||||
use Amasty\ElasticSearch\Model\Synonym;
|
||||
use Psr\Log\LoggerInterface as Logger;
|
||||
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
|
||||
|
||||
class Grid extends SearchResult
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $document = Synonym::class;
|
||||
|
||||
//phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
|
||||
public function __construct(
|
||||
EntityFactory $entityFactory,
|
||||
Logger $logger,
|
||||
FetchStrategy $fetchStrategy,
|
||||
EventManager $eventManager,
|
||||
$mainTable = SynonymInterface::TABLE_NAME,
|
||||
$resourceModel = \Amasty\ElasticSearch\Model\ResourceModel\Synonym::class
|
||||
) {
|
||||
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user