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:

  1. {{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.)

All Products

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:

  1. {{block type="catalog/product_list" name="home.catalog.product.list" alias=" products_ homepage" template="catalog/product/list.phtml"}}

All Products from one Category

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:

  1. {{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

Layout Update XML for magento 1.4

Because in 1.4 version Layout update is different than in 1.3 version, you can use this example:

  1. <reference name="content">
  2.       <block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
  3.           <action method="setCategoryId"> <category_id>[category id here] </category_id> </action>
  4.       </block>
  5. </reference>

New products - Layout Update XML for magento 1.4

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

  1. <reference name="content">
  2.       <block type="catalog/product_new" template="catalog/product/new.phtml">
  3.           <action method="setProductsCount">5 </action>
  4.           <actionmethod="addColumnCountLayoutDepend"> <layout>empty </layout> <count>6 </count> </action>
  5.           <actionmethod="addColumnCountLayoutDepend"> <layout>one_column </layout> <count>5 </count> </action>
  6.           <actionmethod="addColumnCountLayoutDepend"> <layout>two_columns_left </layout> <count>4 </count> </action>
  7.           <actionmethod="addColumnCountLayoutDepend"> <layout>two_columns_right </layout> <count>4 </count> </action>
  8.           <actionmethod="addColumnCountLayoutDepend"> <layout>three_columns </layout> <count>3 </count> </action>
  9.       </block>
  10. </reference>

转载于:https://www.cnblogs.com/alex-13/p/3279028.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值