【问题标题】:Magento 2 Advance Search sort by categoryMagento 2 Advance Search 按类别排序
【发布时间】:2018-11-23 09:44:12
【问题描述】:

我想显示具有类别位置的高级搜索产品, 但我不知道我需要为此调用哪个事件。

【问题讨论】:

    标签: php magento2 advanced-search


    【解决方案1】:

    这是按类别位置对产品进行排序的代码。

    $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()
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多