如何加上「;“按日期缩短”;在Magento上加载类别选项卡滑块时?

如何加上「;“按日期缩短”;在Magento上加载类别选项卡滑块时?,magento,Magento,我在我的magento主题上使用Bxslider v4.0作为类别选项卡滑块,但产品已按产品ID显示 我想做的是按照新的起始日期对项目进行排序,这样我就可以先得到最新的项目 这是滑块代码,也许你能帮上忙。 app/code/local/magentothem function getProductCate($id = NULL) { $storeId = Mage::app()->getStore()->getId(); $_category = Mage::getM

我在我的magento主题上使用Bxslider v4.0作为类别选项卡滑块,但产品已按产品ID显示

我想做的是按照新的起始日期对项目进行排序,这样我就可以先得到最新的项目

这是滑块代码,也许你能帮上忙。 app/code/local/magentothem

function getProductCate($id = NULL) {
    $storeId = Mage::app()->getStore()->getId();
    $_category = Mage::getModel('catalog/category')->load($id);
    $product = Mage::getModel('catalog/product');
    $json_products = array();
    //load the category's products as a collection
    $_productCollection = $product->getCollection()
            ->addAttributeToSelect(array('name', 'price', 'small_image', 'special_price'))
            ->addCategoryFilter($_category);
            Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_productCollection);
            Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($_productCollection);
    $productLimits = $this->getProductsCount();
    if(!$productLimits) $productLimits = 10;
    $_productCollection->setPageSize($productLimits);
    $_productCollection->load();
    return $_productCollection;

$\u productCollection->load()前的,添加:

$_productCollection ->addAttributeToSort('created_at', 'DESC');
如果要排序的字段不是在
处创建的,请将其替换为正确的名称(不确定我是否理解该问题)