Magento首页显示产品
Magento首页显示产品
不过没有针对 具体使用过程中遇到的情况进行修正
这边只做一个备忘吧 (细节问题 按个别情况进行修改即可)
New products
Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show products labeled as “new” on your front page:
-
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
(Note that you must have some new products in your catalogue for anything to show when you do this. In this context new doesn’t mean that you’ve recently added them; only products explicitly marked as new using ‘Set Product as New from Date’ and ‘Set Product as New to Date’ options in the ‘General’ product information page in the admin tool will be shown.)
Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show all products in your catalog on your front page:
-
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show one category on your front page:
-
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
The category ID can be found when you go to “manage category” and then select the category you want. The ID is written in the header.
Examples is outdated, dosent work in magento 1.4.1
Because in 1.4 version Layout update is different than in 1.3 version, you can use this example:
-
<reference name="content">
-
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
-
<action method="setCategoryId"><category_id>[category id here]</category_id></action>
-
</block>
-
</reference>
To display new product / latest product, you can use this following XML code in layout xml file or layout display in backend. You can use also the widgets to display the products. The code below has been inspired by the widget.
diglin
-
<reference name="content">
-
<block type="catalog/product_new" template="catalog/product/new.phtml">
-
<action method="setProductsCount">5</action>
-
<actionmethod="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
-
<actionmethod="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
-
<actionmethod="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
-
<actionmethod="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
-
<actionmethod="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
-
</block>
-
</reference>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?