標籤:des style http ar io os sp for on
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的最小值