【发布时间】:2015-09-30 04:08:51
【问题描述】:
我知道这个问题被问了很多,而且看起来很直截了当,但我似乎找不到说明有效答案的帖子。
有一些解决方案介绍了如何在后端列出标有“新开始”日期的产品,还有一些解决方案列出了特定类别的最新产品,但我只需要 8 个最近添加到目录中的产品句号。
目前我正在手动将产品添加到 ID 为 116 的“最新产品”类别中
并在我的主页 CMS 页面的内容中包含此内容:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="116" template="catalog/product/list-latest.phtml"}}
然后在list-latest.phtml模板文件中,我有一些代码来获取集合:
<?php
$_productCollection=$this->getLoadedProductCollection()->setPageSize(10);
$_productCollection->clear(); //this will unset the loaded items.
$_productCollection->getSelect()->limit(10); //set a new limit
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER); //reset the order
$_productCollection->getSelect()->order('cat_index_position asc');//force order by position in category
$_productCollection->load();
$_helper = $this->helper('catalog/output');
?>
然后它会遍历集合并正常工作,但我需要一种方法来获取所有类别的最新产品并自动将最新的 8 种产品放在主页上。
有没有办法改变这段代码来做到这一点?
【问题讨论】:
标签: magento magento-1.9