2012年6月16日星期六 Asia/Shanghai上午11时39分22秒

有的时候,我们想输出产品的tier price 的最小值!如图:

下面是解决的办法:

1.

在catalog/product/view文件夹下新建一个文件: getlowest.phtml
<?php

/**
* @E-Commercewebdesign.co.uk
*/
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true); $_weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($_product);
if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) {
$_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
} ?>
<?php if (count($_tierPrices) > 0): ?>
<?php if ($this->getInGrouped()): ?>
<?php $_tierPrices = $this->getTierPrices($_product); ?>
<?php endif; ?>
<?php Mage::helper('weee')->processTierPrices($_product, $_tierPrices); ?>
<?php $i = 0; ?>
<?php $_tierPrices = array_reverse($_tierPrices); ?>
<?php foreach ($_tierPrices as $_price): ?>
<?php if($i==0){ ?>
<p style="font-weight:bold; font-size: 1em;">After tier pricing the lowest price you can have a Cowboy Hat is...
<span style="font-size:150%; text-decoration:underline;">
<?php echo $_price['formated_price']; ?>
</span>
<p>
<?php $i++; ?>
<?php } ?>
<?php endforeach ?>
<?php endif;?>

2.

在catalog_product_view这个block下面加入这个block

<block type="catalog/product_view" name="getlowest" as="getlowest" template="catalog/product/view/getlowest.phtml" />

3.

在希望显示tier price最小值的地方,调用下面的代码:

<?php echo $this->getChildHtml('getlowest') ?>

然后就会显示出来,如果我们想在其他页面调用,譬如产品列表页面调用,可以按照下面的方式操作

public function getLowestPrice($_product)
{
$prices = new Mage_Bundle_Block_Catalog_Product_View();
$_tierPrices = $prices->getTierPrices($_product);
$count = $_product->getTierPriceCount();

if ($count > 0):
$i = 0;
$_tierPrices = array_reverse($_tierPrices);

foreach ($_tierPrices as $_price):
if($i==0){
return $_product->getFormatedTierPrice($_price);
$i++;
}
endforeach;
endif;
}

通过这个函数调用就可以得到!

OK,完毕!

在magneto系统中输出tier price的最小值的更多相关文章

  1. 在Linux和Windows系统中输出目录结构

    前言 一直以来就想在写文章时,能以文本形式(而不是截图)附上项目的目录结构,今天终于知道怎么操作了,在这分享一下. Linux 首先说下Linux上输出目录结构的方法. yum安装tree 需要支持t ...

  2. 【转】JAVA输出内容打印到TXT以及不同系统中如何换行

    JAVA输出内容打印到TXT以及不同系统中如何换行 http://xiyang.09.blog.163.com/blog/static/59827615201172552755293/ 2011-08 ...

  3. linux系统中批量查找文件与文件内容的方法

    在linux中查看与修改文件权限我们都必须使用命令来操作,不能像windows一样点几下就好了,下面我们简单的介绍一下linux中的相关命令 比如查找当前目录下面所有的php文件里面某个关键字 fin ...

  4. Windows下USB磁盘开发系列二:枚举系统中所有USB设备

    上篇 <Windows下USB磁盘开发系列一:枚举系统中U盘的盘符>介绍了很简单的获取系统U盘盘符的办法,现在介绍下如何枚举系统中所有USB设备(不光是U盘). 主要调用的API如下: 1 ...

  5. 让Redis在你的系统中发挥更大作用的几点建议

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/105.html?1455868313 Redis在很多方面与其他数据库解决 ...

  6. 李学斌:论复杂系统中的应用间协作V3

    说明 本文主要讨论了巨型复杂业务系统的一种构建思路,力图实现决策意志的快速.准确.一致的下传并简化实施成本提供实施效率.通过全业务领域的即时流程编排,实现全网业务IT系统的快速建设与迭代.本文所讲的方 ...

  7. Linux系统中“动态库”和“静态库”那点事儿 /etc/ld.so.conf 动态库的后缀为*.so 静态库的后缀为 libxxx.a ldconfig 目录名

    Linux系统中“动态库”和“静态库”那点事儿 /etc/ld.so.conf  动态库的后缀为*.so  静态库的后缀为 libxxx.a   ldconfig   目录名 转载自:http://b ...

  8. 用户管理 之 Linux 系统中的超级权限的控制

    在Linux操作系统中,root的权限是最高的,也被称为超级权限的拥有者.普通用户无法执行的操作,root用户都能完成,所以也被称之为超级管理用户. 在系统中,每个文件.目录和进程,都归属于某一个用户 ...

  9. exit()与_exit()函数的区别(Linux系统中)

    注:exit()就是退出,传入的参数是程序退出时的状态码,0表示正常退出,其他表示非正常退出,一般都用-1或者1,标准C里有EXIT_SUCCESS和EXIT_FAILURE两个宏,用exit(EXI ...

随机推荐

  1. Gliffy

    http://www.gliffy.com Gliffy 支持在线制作流程图,能够很好的支持中文,基础版本免费.在线制作的思维导图是公开的,高级版本有设置隐私权的权力.可以嵌入博客,办公室应用软件中, ...

  2. ajax异步加载小例子....(通俗易懂)

    web.html(用户端): <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  3. li排序的两种方法

    1.一般做法 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...

  4. bzoj 2561: 最小生成树

    #include<cstdio> #include<iostream> #include<cstring> #define M 100009 #define inf ...

  5. PowerMock使用遇到的一些问题

    首先使用PowerMock  Mock对象如果不成功的话首先要检查在测试类上是否有这两个声明@RunWith(PowerMockRunner.class)                        ...

  6. C++之函数fgetc和fputc、fgets和fputs、fread和fwrite、fscanf和fprintf用法小结

    #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int ...

  7. [转载]Android View.onMeasure方法的理解

    2013-12-18 10:56:28 转载自http://blog.sina.com.cn/s/blog_61fbf8d10100zzoy.html View在屏幕上显示出来要先经过measure( ...

  8. wsgi协议

    用来为server程序和app/framework程序做连接桥梁的,使server和app/framework各自发展,任意组合 上图是python3.4标准库里面,关于wsgiserver的实现.从 ...

  9. Spring学习笔记之Constructor-based or setter-based DI?

    如果是强制依赖,那么使用构造器注入,如果是可选依赖,那么使用set方法注入.Spring鼓励构造器注入,可以确保依赖项不为null, Since you can mix constructor-bas ...

  10. APP store 审核注意点

    磨刀不误砍柴工.作为手机应用开发者,你需要向应用商店提交应用审核,迅速通过审核可以让你抢占先机.对苹果iOS应用开发者来说尤其如此.苹果应用商店的审核近乎吹毛求疵,下面这些清单可以让你知道苹果会在哪些 ...