Magento在类别列表中显示最佳Teirprice

时间:2014-09-23 11:20:36

标签: arrays magento magento-1.7

在Magento 1.7中显示最佳等级价格的问题

以下代码效果非常好,但它只获得第一个数组价格,因此它不是最佳的多买单价格。

<?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 */ ?>

任何显示最佳等级价格的帮助都会很棒,

提前感谢...

1 个答案:

答案 0 :(得分: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 */ ?>