搜索结果显示


Search result display

嗨,我正在尝试显示按attribute_set_id排序的搜索结果。我想将它们显示为第一个attribute_set名称的标题,然后是属于 attribute_set_id 1 的产品,然后是 attribute_set 2 的标题,然后是属性集 2 中的产品

有人知道我如何做到这一点吗?

我尝试通过以下代码对结果列表进行排序

    <?php $_productCollection = clone $this->getLoadedProductCollection();
    $_productCollection->clear()
        ->addAttributeToSelect('*')
        ->addAttributeToSort('attribute_set_id', 'DESC')
        ->load();
    ?>   

如果您收到集合但无法对其进行排序,请尝试使用 ->setOrder('attribute_set_id', 'DESC'),因为 ->addAttributeToSort 仅适用于 EAV 类型

setOrder($field, $direction = self::SORT_ORDER_DESC)来自Varien/Data/Collection.php所以应该可以正常工作