Skip to content
Snippets Groups Projects
Commit 35d4b141 authored by Sviatoslav Mankivskyi's avatar Sviatoslav Mankivskyi
Browse files

MAGETWO-47168: Stabilization

parent 054de00a
Branches
No related merge requests found
......@@ -33,6 +33,35 @@ class FulltextFilter implements FilterApplierInterface
return [];
}
/**
* Add table alias to columns
*
* @param array $columns
* @param DbCollection $collection
* @param string $indexTable
* @return array
*/
protected function addTableAliasToColumns(array $columns, DbCollection $collection, $indexTable)
{
$alias = '';
foreach ($collection->getSelect()->getPart('from') as $tableAlias => $data) {
if ($indexTable == $data['tableName']) {
$alias = $tableAlias;
break;
}
}
if ($alias) {
$columns = array_map(
function ($column) use ($alias) {
return '`' . $alias . '`.' . $column;
},
$columns
);
}
return $columns;
}
/**
* Apply fulltext filters
*
......@@ -46,6 +75,7 @@ class FulltextFilter implements FilterApplierInterface
if (!$columns) {
return;
}
$columns = $this->addTableAliasToColumns($columns, $collection, $collection->getMainTable());
$collection->getSelect()
->where(
'MATCH(' . implode(',', $columns) . ') AGAINST(?)',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment