Reputation: 139
I need to show qty field for tier_price near regular price in product list (highest qty for lowest tier_price). Now $_product->getTierPrice() in product list gives me array(1) with 'tier_price'=>xxx and 'qty'=>1 (where xxx is lowest of my tier prices). Is it possible to get qty for tier_price in product list?
PS. In product view I can see array of tier prices with $_product->getTierPrice().
Magento CE 1.7.0.2
Upvotes: 0
Views: 2015
Reputation: 11
You can put this code in list.phtml or in view.phtml to show tier prices for each quantity.
$attribute = $_product->getResource()->getAttribute('tier_price');
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
$symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
if ($attribute) {
$attribute->getBackend()->afterLoad($_product);
$tierPrices = $_product->getTierPrice();
foreach($tierPrices as $tierPrice)
{
?>
<span class="priceqty"><?php echo '+'.round($tierPrice["price_qty"], 0);?></span><br>
<span class="pricetitle"><?php echo $symbol.number_format($tierPrice["price"], 2, '.', '');?></span>
<?php
}
}
?>
Upvotes: 1
Reputation: 5674
If you are looking for a Magento way:
$attribute = $_product->getResource()->getAttribute('tier_price');
if ($attribute) {
$attribute->getBackend()->afterLoad($_product);
$tierPrices = $_product->getTierPrice();
}
From /app/code/core/Mage/Catalog/Model/Product/Type/Price.php
getTierPrice()
I have tested on Magento 1.4.0.2 (it should work also on other version ) on category pages and it works
In case you want to do it with SQL look here: Magento: Display tier prices at category listing page
Upvotes: 0