这个需要我们自己添加一个block块供我们调用,可参考new products的block类,建立文件app/code/core/Mage/Catalog/Block/Product/Special.php

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    <?php  
    class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_Abstract  
    {  
        protected $_productsCount= null;  
        const DEFAULT_PRODUCTS_COUNT = 5;
 
        protected function _beforeToHtml()  
        {  
            $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);  
            $collection = Mage::getResourceModel('catalog/product_collection');  
            Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);  
            Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);  
            $collection = $this->_addProductAttributesAndPrices($collection)  
                        ->addStoreFilter()  
                        ->addAttributeToFilter('special_from_date',array('date'=> true,'to'=>$todayDate))  
                        ->addAttributeToFilter('special_to_date',array('or'=>array(0=>array('date'=> true,'from'=>$todayDate),1=>array('is'=>new Zend_Db_Expr('null')))),'left')  
                        ->addAttributeToSort('special_from_date','desc')  
                        ->setPageSize($this->getProductsCount())  
                        ->setCurPage(1);  
            $this->setProductCollection($collection);  
            return parent::_beforeToHtml();  
        }  
        public function setProductsCount($count)  
        {  
            $this->_productsCount = $count;  
            return $this;  
        }  
        public function getProductsCount()  
        {  
            if(null === $this->_productsCount)  
            {  
                $this->_productsCount = self::DEFAULT_PRODUCTS_COUNT;  
            }  
            return $this->_productsCount;  
        }  
    }

复制app/design/frontend/base/default/template/catalog/product/new.phtml到app/design/frontend/theme/default/template/catalog/product/special.phtml,修改为相应标题和产品显示数量
在后台首页的CMS Page模块添加调用代码:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
<block type="catalog/product_special" name="home.catalog.product.special" alias="product_special" template="catalog/product/special.phtml" after="cms_page">
    <action method="addPriceBlockType">
        <type>bundle</type>
        <block>bundle/catalog_product_price</block>
        <template>bundle/catalog/product/price.phtml</template>
    </action>
    <action method="setColumnCount">
        <count>4</count>
    </action>
    <action method="setProductsCount">
        <count>4</count>
    </action>
        </block>

当然要想显示特价产品,在产品管理处还是要设置的,进入产品管理的Prices栏,Special Price和Special Price From Date都要设置,那么前台就会显示特价产品。

magento首页调用最新产品的更多相关文章

  1. Magento首页显示产品

    Magento首页显示产品     经常用的比较琐碎,上官网发现一个稍微全一点的不过没有针对 具体使用过程中遇到的情况进行修正  这边只做一个备忘吧   (细节问题 按个别情况进行修改即可) New  ...

  2. ecshop首页调用团购信息产品购买人数

    当我们在ecshop后台录入ecshop的团购信息之后,我们在ecshop的前台首页index.php里面,可以看到他能调用ecshop的团购商品信息,其中就包括团购商品的一些价格信息.但是如何在ec ...

  3. 如何更改/删除magento首页产品/广告图片等模块信息

    如何更改/删除magento首页产品/广告图片等模块信息,如果只是修改一些简单的地方,例如已经存在 的左右栏目里面的图片内容等,是很简单的,直接在后台就可以修改的,具体如下: 如何删除magento首 ...

  4. phpcms首页调用会员头像及金钱、积分等信息,并按照积分点数排列

    <div class="box"> <h5>最新会员</h5> <div class="col-auto">&l ...

  5. 帝国cms调用最新文章 利用文字调用标签phomenews

    最近建站时,朋友要求在头部用帝国cms调用最新文章,当时想了用灵动标签调用,但需要设置一个具体的栏目id,这样就不是调用全站的最新文章了,后面查看了一下标签说明,想到了文字调用标签phomenews. ...

  6. ECShop怎么首页调用文章列表

    举例如首页调用方法:1.先打开index.php文件找到以下代码:$smarty->assign('new_articles', index_get_new_articles()); // 最新 ...

  7. G:首页调用“图片视频”的分类和文章(难点)

      1:后台获取:自定义分类的ID (默认分类也可获取)  2:动态获取"自定义分类的ID($cat)"  $cat_title = single_cat_title(' ', f ...

  8. dede使用方法----如何调用最新文章,最热文章,友情链接

    dede如何调用最新文章 {dede:arclist      row='5'       titlelen='50'    orderby ='pubdate'} <li><a h ...

  9. 织梦DedeCMS首页调用单页文档内容的方法

    很多使用织梦dedecms单页文档功能的朋友都想知道如何在织梦首页调用单页文档的内容,下面就教大家具体的实现方法: 具体步骤如下: 首先在首页模板需要显示单页文档内容的地方插入如下代码: {dede: ...

随机推荐

  1. 转--CSS选择器详解(一)常用选择器

    今天复习一下CSS的知识,看了篇文章觉得很好,转来备用. 转自:http://www.cnblogs.com/fattydoit/p/3492028.html 目录 类型选择器 类选择器 ID选择器 ...

  2. 多线程相关Interlocked.Increment问题

    今天群里有人问到如下代码打印出来的东西为什么不是连续得,所以有大神解释了原因.在这过程中遇到了些奇怪的情况 static void Main(string[] args) { for (int i = ...

  3. js ——算法

    1.使用js 数组去重复: 方法①: var arr=[1,2,1,5,2,3,5,1,6,9]; function deRepeat(){ var newArray=[]; var obj={}; ...

  4. PHP的那些坑

    1.urlencode urlencode编码的对象必须是utf-8编码.如果是其它格式的编码就会出现乱码. 2.array_merge 一般来说,array_merge就是把两个或两个以上的数组组合 ...

  5. 230. Kth Smallest Element in a BST ——迭代本质:a=xx1 while some_condition: a=xx2

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...

  6. GO工程和包

    转载:http://blog.csdn.net/achelloworld/article/details/43956831 在Go语言中,包是函数与数据的集合,用package定义一个包,包的名字不一 ...

  7. BZOJ3888 [Usaco2015 Jan]Stampede

    我们只要把每头牛开始遮挡视线和结束遮挡视线的时间点都搞出来就好= = 再按照y轴排序...然后变成线段覆盖了..线段树搞一下就好了? /******************************** ...

  8. thinking in java 之Reference类的使用

    Reference是java中的特殊引用类.描述的是特殊作用(主要是关于垃圾回收对象)的引用. 它有3个子类: 1.SoftReference; 2.WeakReference 3.PhantomRe ...

  9. C#压缩图片1

    using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;us ...

  10. Android Webview 背景透明

    两个关键点: 1         fBarParams.format = PixelFormat.RGBA_8888; 2 mWebView.setBackgroundColor(Color.TRAN ...