Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 用于搜索条件的自定义筛选器。马根托2号_Magento_Search_Filter_Criteria - Fatal编程技术网

Magento 用于搜索条件的自定义筛选器。马根托2号

Magento 用于搜索条件的自定义筛选器。马根托2号,magento,search,filter,criteria,Magento,Search,Filter,Criteria,我需要添加一年的范围过滤器。我在模块全文\集合中重新定义了Magento类。我还在search_request.xml文件中进行了更改。我找到了代码,它对我有效: $SKU=[ “CNS334”, ‘U012840’ ]; $this->filterBuilder->setField('sku'); $this->filterBuilder->setValue($skus); $this->filterBuilder->setCondi

我需要添加一年的范围过滤器。我在模块全文\集合中重新定义了Magento类。我还在search_request.xml文件中进行了更改。我找到了代码,它对我有效:

$SKU=[ “CNS334”, ‘U012840’ ];

    $this->filterBuilder->setField('sku');
    $this->filterBuilder->setValue($skus);
    $this->filterBuilder->setConditionType('in');

    $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
但我在另一个表中有数据。我尝试加入,但我无法获得任何筛选结果

   $this->getSelect()->join(
        [
            'my' => 'make_year',
        ],
        'e.entity_id = my.product_id'

$this->searchCriteriaBuilder->addFilter($this->filterBuilder
        ->setField('year')
        ->setValue(2014)
        ->setConditionType('from')
        ->create());

$this->searchCriteriaBuilder->addFilter($this->filterBuilder
        ->setField('year')
        ->setValue(2015)
        ->setConditionType('to')
        ->create());

    $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());

要将查询与其他表联接,您需要条件映射器

作为一个例子,请看-这里是启动过滤器

data
数组中设置新项将触发映射器方法

此映射程序包含
\Magento\Framework\DB\Select
,我们可以像在旧式集合中一样使用它。 映射器方法的名称与标准的
数据
数组索引相关。因此,如果添加
$this->data['custom\u field']
映射器函数应该是
mapCustomField()


还请注意,如果字段有特定的映射器函数,映射器将尝试按其进行筛选。

要将查询与其他表连接,您需要criteria mapper

作为一个例子,请看-这里是启动过滤器

data
数组中设置新项将触发映射器方法

此映射程序包含
\Magento\Framework\DB\Select
,我们可以像在旧式集合中一样使用它。 映射器方法的名称与标准的
数据
数组索引相关。因此,如果添加
$this->data['custom\u field']
映射器函数应该是
mapCustomField()


还请注意,如果该字段有特定的映射器函数,映射器将尝试按其进行筛选。

失效github链接失效github链接失效