magento创建自定义页面 (Bestseller实例) Bes

系统 1778 0

Bestseller or best selling product is one of the features people tend to ask for when it comes to Magento™.

 

There are multiple ways to implement this feature.

In this example, I’m not using controller or model directories at all; I’m going to show you how to implement this feature using only one file: the View.

 

Basically, what you need to do is to create the directory inside your template directory and place the bestseller.phtml file in it. In my example, I’m using the custom-created directory /inchoo . All of the screenshots provided here are based on that directory structure.

Adding this feature to your store is a matter of two simple steps:

  • copy bestseller-phtml file to your directory
  • display the block on home page

 

To add a block to a home page, you simply log into the Magento, CMS > Manage Pages > Home. Then add the following to the content area:

        {{block type="core/template" template="inchoo/bestseller.phtml"}}
      
 

Notice the type attribute. I used core /template which means you can place this code anywhere in your site and it will work. Code does not inherit any collection objects from controllers since it has none. All that is necessary for the bestseller.phtml to work is defined in that single file.

 

 

One more thing: If you study the code in bestseller.phtml file you will see, at the very top of the file, the part that says: $this->show_total .

 

If I were to write

        {{block type="core/template" show_total="12" template="inchoo/bestseller.phtml"}} 
      
 

in my home page, then $this would be assigned property show_total with a value of 12 .

 

 

Therefore, the provided bestseller.phtml file provides the option of setting the number of products you wish to see listed.

 

 

Here is the bestseller.phtml packed in bestseller .zip.

Hope you find this useful.

 

来源: http://inchoo.net/ecommerce/magento/bestseller-products-in-magento/

magento创建自定义页面 (Bestseller实例) Bestseller products in Magento


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论