Skip to content

Instantly share code, notes, and snippets.

@anoriar
Last active March 16, 2019 11:09
Show Gist options
  • Save anoriar/1b049ecdf66d9da49a9bcd093878bf3a to your computer and use it in GitHub Desktop.
Save anoriar/1b049ecdf66d9da49a9bcd093878bf3a to your computer and use it in GitHub Desktop.
Array
(
[index] => products
[type] => models
[sort] => Array
(
[0] => SORT:desc
)
[body] => Array
(
[query] => Array
(
[filtered] => Array
(
[filter] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[term] => Array
(
[PROPERTIES.COLLECTION] => 3885349
)
)
[1] => Array
(
[term] => Array
(
[PROPERTIES.COLLECTION] => 3885351
)
)
)
)
)
)
)
)
[size] => 50
[from] => 0
)
bitrix/modules/aero.elastic/lib/catalog/prototype.php
getElements
$arr = [
"must" => [
0 => [
"term" => [
"PROPERTIES.COLLECTION" => 3885349
]
],
1 => [
"term" => [
"PROPERTIES.COLLECTION" => 3885351
]
]
]
];
$params["body"]["query"]["filtered"]["filter"]["bool"] = $arr;
переопределить getFilter
переопределить getFilter
bitrix/modules/aero.elastic/lib/catalog/prototype.php
elseif(in_array('AND', $filterParam)){
foreach ($filterParam as $filterParamLogic) {
if ($filterParamLogic == 'AND') {
continue;
} else {
$param = reset($filterParamLogic);
$key = reset(array_keys($filterParamLogic));
if (is_array($param)) {
$tCode = 'terms';
} else {
$tCode = 'term';
}
$isRangeFilterSet = $this->setRangeFilter($arFilter, $key, $param, 'should');
if (!$isRangeFilterSet) {
$arFilter['bool']['must'][] = [
$tCode => [
$key => $param,
],
];
}
}
}
}
запрос:
$productsInst = \Aero\Tools\Iblock\Catalog\Products::getInstanceByCode();
$collection1 = 3885349;
$collection2 = 3885351;
$collection3 = 3885350;
$products = $productsInst->getElementsES([
"select" => ["ID", "NAME", "PROPERTIES.COLLECTION"],
"filter" => [
[
'LOGIC' => 'AND',
['PROPERTIES.COLLECTION' => $collection1],
['PROPERTIES.COLLECTION' => [$collection2, $collection3]]
],
]
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment