Magento 2 高级搜索按类别排序
Magento 2 Advance Search sort by category
我想显示分类位置排序的高级搜索产品,
但我不知道为此需要调用哪个事件。
这是按类别位置对产品进行排序的代码。
$this->_productCollection->getSelect()
->joinLeft(
['category' => 'catalog_category_product', 'cp' => 'catalog_category_entity'],
'e.entity_id = category.product_id',
['category.category_id']
)
->joinLeft(
['cp' => 'catalog_category_entity'],
'category.category_id = cp.entity_id',
['cp.position']
)->group('e.entity_id');
$this->_productCollection->getSelect()->order(
'cp.position ' . $this->getCurrentDirectionReverse()
);
我想显示分类位置排序的高级搜索产品, 但我不知道为此需要调用哪个事件。
这是按类别位置对产品进行排序的代码。
$this->_productCollection->getSelect()
->joinLeft(
['category' => 'catalog_category_product', 'cp' => 'catalog_category_entity'],
'e.entity_id = category.product_id',
['category.category_id']
)
->joinLeft(
['cp' => 'catalog_category_entity'],
'category.category_id = cp.entity_id',
['cp.position']
)->group('e.entity_id');
$this->_productCollection->getSelect()->order(
'cp.position ' . $this->getCurrentDirectionReverse()
);