|
首页 ::
Magento开发 ::
Magento安装设置 ::
magento首页显示产品
 |
 |
 |
|
magento首页显示产品 作者: Magento | 2012-03-08 阅读次数:2359 关键字:深圳magento优化
1.首先现在magento后台创建一个新的分类,记下这个分类的 ID 号码。使用这个新建的分类来管理你的首页产品,这个分类设置为前台不可见。这样就不会显示在你的分类菜单中了,但使用代码调用的时候却会显示出来。

2.在cms–>manage page–>home 适当位置添加如下代码(例如代码的最后)
1
|
{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml"}}
|
(注意编码,你直接复制黏贴可能不行,要是英文的标点符号,不行就切换到英文输入法,然后自己手动的敲下。关闭你的所见即所得编辑器,再在如下图中的“内容”中黏贴此代码)
使用xml来显示的话,在如下图中的“设计”中,添加XML代码如下
1
2
3
4
5
|
< 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 >
|
代码解释如下:
我们在magento后台新建一个分类,向这个分类中添加的产品会在首页显示。在magneto成功添加一个分类后,会给这个分类分配一个ID。红色部分“category_id”的值“3”既是此分类ID。“list.phtml”既是此产品列表的模板样式文件。
XML中的template是指模板路径,[category id here],包括中括号都删掉换成你的分类的ID号。如果想在首页显示产品,这段xml加在 后台CMS homepage这个page的layout update中。如下图
Magento安装设置的相关新闻
更早的新闻
|
|
 |
 |
 |
|