init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Ui\DataProvider\SpecificationFile;
|
||||
|
||||
use Esun\Catalog\Model\ResourceModel\SpecificationFile\CollectionFactory;
|
||||
use Magento\Framework\Api\Filter;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
|
||||
class ListingDataProvider extends AbstractDataProvider
|
||||
{
|
||||
public function __construct(
|
||||
string $name,
|
||||
string $primaryFieldName,
|
||||
string $requestFieldName,
|
||||
CollectionFactory $collectionFactory,
|
||||
array $meta = [],
|
||||
array $data = []
|
||||
) {
|
||||
$this->collection = $collectionFactory->create();
|
||||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
|
||||
}
|
||||
|
||||
public function addFilter(Filter $filter): void
|
||||
{
|
||||
if ($filter->getField() !== 'fulltext') {
|
||||
parent::addFilter($filter);
|
||||
return;
|
||||
}
|
||||
|
||||
$connection = $this->collection->getConnection();
|
||||
$value = '%' . (string)$filter->getValue() . '%';
|
||||
$this->collection->getSelect()->where(
|
||||
$connection->quoteInto('brand_name LIKE ?', $value)
|
||||
. ' OR '
|
||||
. $connection->quoteInto('model_name LIKE ?', $value)
|
||||
. ' OR '
|
||||
. $connection->quoteInto('file_path LIKE ?', $value)
|
||||
. ' OR '
|
||||
. $connection->quoteInto('file_name LIKE ?', $value)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user