2014-09-23 49 views
0

有一個問題顯示的最佳梯隊價格在Magento 1.7Magento的顯示在類別列表

下面的代碼工作得很好,但它僅獲得第一個數組價格最好Teirprice,所以它可能不是最好的多買一層價格。

<?php 
        /* get the data */ 


        $my_tier_rocks = $this->getTierPrices(); 
        if (!empty($my_tier_rocks)){ 
         $my_tier_rocks = $this->getTierPrices(); 

          // Notice you may not be using formated_price_incl_tax but other field. 
          $my_tier_rocks = $my_tier_rocks[0]['formated_price_incl_tax']; 

          $_savingPercent = round((($my_tier_rocks-$_finalPrice)/$my_tier_rocks)*100,1); 

        ?> 
        <? /* let's print the data */ ?> 
        <? /* Use the HTML you want just notice the $my_tier_rocks var */ ?> 
        <span class="cat_multibuyprice">      
         <span class="label"><?php echo $this->__('Multi Buy Price:') ?></span> 
         <span class="price"><?=$my_tier_rocks?></span>    
        </span> 

        <?php $_savingAmount = $_regularPrice-$_finalPrice; ?> 

        <? } /*end showing tier prices */ ?> 

任何幫助,以表現出最佳的一線價格將是巨大的,提前

感謝...

回答

0

好吧,我傻。

我只是使用end($ array);以獲得陣列的最後和最佳價格。

<?php 
        /* get the data */ 


        $my_tier_rocks = $this->getTierPrices(); 
        if (!empty($my_tier_rocks)){ 
         $my_tier_rocks = $this->getTierPrices(); 

          // Notice you may not be using formated_price_incl_tax but other field. 
           $my_tier_best_price = end($my_tier_rocks); 

            $my_tier_rocks = $my_tier_best_price['formated_price_incl_tax']; 

           $_savingPercent = round((($my_tier_rocks-$_finalPrice)/$my_tier_rocks)*100,1); 

        ?> 
        <? /* let's print the data */ ?> 
        <? /* Use the HTML you want just notice the $my_tier_rocks var */ ?> 
        <span class="cat_multibuyprice">      
         <span class="label"><?php echo $this->__('Multi Buy Price:') ?></span> 
         <span class="price"><?=$my_tier_rocks?></span>    
        </span> 

        <?php $_savingAmount = $_regularPrice-$_finalPrice; ?> 

        <? } /*end showing tier prices */ ?>