Magento按价格分类相关产品 [英] Magento sorting related products by price

查看:70
本文介绍了Magento按价格分类相关产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我一直在尝试按降序排列的相关产品(最便宜的价格和最便宜的价格)对相关产品进行排序,到目前为止没有任何运气,也许有人可以指导我如何做到这一点?

i've been trying to sort related products by price in descending oreder (cheapest at the top and expensive at bottom) without any luck so far, maybe someone could guide me on how to do that?

推荐答案

查看此文件app \ code \ core \ Mage \ Catalog \ Model \ Product.php并选中此功能行814

See this file app\code\core\Mage\Catalog\Model\Product.php and check this function line 814

public function getRelatedProductCollection()
{
    $collection = $this->getLinkInstance()->useRelatedLinks()
        ->getProductCollection()
        ->setIsStrongMode();
    $collection->setProduct($this);
    return $collection;
}

您需要通过扩展此Model类来修改此函数,因此首先创建一个Module并将此函数写入您的函数中.并将订单"添加到集合中.

You need to modify this function by extend this Model Class so first Create an Module and Write this function inside your function. and add Order to collection.

$collection->setOrder('price', 'DESC');


public function getRelatedProductCollection()
{
    $collection = $this->getLinkInstance()->useRelatedLinks()
        ->getProductCollection()
        ->setIsStrongMode();
    $collection->setProduct($this);
    $collection->setOrder('price', 'DESC');
    return $collection;
}

您需要扩展此模块Mage_Catalog_Model_Product并修改此功能

You need to Extend this Module Mage_Catalog_Model_Product and also modify this function

这篇关于Magento按价格分类相关产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆