在magneto系統中輸出tier price的最小值

來源:互聯網
上載者:User

標籤: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的最小值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.