在 Magento 上加载类别选项卡滑块时如何添加 "Short by Date"?

How to add "Short by Date" when loading category tab slider on Magento?

我在我的 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;

在行 $_productCollection->load(); 之前添加:

$_productCollection ->addAttributeToSort('created_at', 'DESC');

如果你要排序的字段不是created_at,请用正确的名称替换它(不确定我是否理解问题)