按ASC排序顺序对Magento相关产品进行排序,空值排在最后(或不包括空)



我的Magento 1.6.2.0安装目前按排序顺序升序对相关产品进行排序(感谢此问答)。那里详细介绍的答案效果很好,但是我更喜欢排序顺序值为 NULL 的产品列在最后或完全排除。我玩过addAttributeToSelect(),但我没有成功。

这可能不是最好的解决方案,但我在我的 related.phtml 文件中添加了一个 if 语句。

    <?php foreach($this->getItems() as $_item): ?>
        // add the if statement immediately after the foreach loop
        <?php if ( !is_null($_item->getPosition()) ): ?>
        . . . .
        <?php endif; ?>
    <?php endforeach; ?>

最新更新