我正在像这样加载我的集合,在将加载扩展的自定义 list.phtml 中
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$listHelper = Mage::helper('customodule);
?>
<?php if(!$_productCollection->count()): ?>
我怎么能用这种方法在集合中调用排序呢?
我知道如何用另一种方法做到这一点,但我需要使用第
一种其他方法:
<?php $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$_productCollection = Mage::getModel('catalog/product')
->getCollection()
->addCategoryFilter(Mage::getModel('catalog/category')->load(4))
->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToSort('news_from_date', 'desc')
->addAttributeToSelect(array('name','url','small_image','price'))
->setPage(1, 10)
->addAttributeToSort('created_at', 'desc')
?>
<?php if(!$_productCollection->count()): ?>