1
当显示Magento类别时,可以在开始时列出任何新产品(具有“新的”和“新的”日期的产品)的集合,以便它们显示在类别的第一页上,而不是基于当前排序的默认位置?在Magento中首次列出的“新”项目中订购产品
是否有必要有两个查询?
谢谢!
当显示Magento类别时,可以在开始时列出任何新产品(具有“新的”和“新的”日期的产品)的集合,以便它们显示在类别的第一页上,而不是基于当前排序的默认位置?在Magento中首次列出的“新”项目中订购产品
是否有必要有两个查询?
谢谢!
守则排序产品通过news_from_date和news_to_date: -
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$productCollection->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');
您可以在类浏览新产品代码Mage_Catalog_Block_Product_New
(应用程序/代码/core/Mage/Catalog/Block/Product/New.php)
希望这有助于。