Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: Display tier prices at category listing page

Tags:

magento

I'm trying to display all tier prices on category listing page (catalog/product/list.phtml) but only getting the basic price for a single product.

print_r($_product->getTierPrice());

returns:

Array
(
    [0] => Array
        (
            [price] => 0.5000
            [website_price] => 0.5000
            [price_qty] => 1
            [cust_group] => 32000
        )

)

for each product. On the product info page it works w/o problems. Please advise.

ver. 1.5.0.1

UPDATE:

Here is the solution for the problem inspired with the answer below:

$resource = Mage::getSingleton('core/resource');
$query = 'SELECT * FROM ' . $resource->getTableName('catalog/product') . '_tier_price';
$_tier_prices = $resource->getConnection('core_read')->fetchAll($query);
var_dump($_tier_prices);
like image 340
user487772 Avatar asked Aug 03 '11 14:08

user487772


People also ask

How do I show special prices in Magento 2?

Magento Open Source includes simple start and end date options in the Advanced Pricing options. Open the product in edit mode. Scroll down to the Price field, click Advanced Pricing, and enter the Special Price amount. ) to choose the Start Date and End Date for the special price promotion.

What is tier price in Magento?

Definition. Tier price in Magento 2 refers to the ability to set a discount based on the volume of items purchased. After hitting each benchmark (tier), customers will enjoy a new and better price. Something like this: This rule will run on a specific store view, customer group, or shared catalog.


2 Answers

This is another way to get the tier prices

Mage::getResourceModel('catalog/product_attribute_backend_tierprice')
            ->loadPriceData($product_id,Mage::app()->getWebsite()->getId());

The response is array with prices

[0] => Array
    (
        [price_id] => 7
        [website_id] => 0
        [all_groups] => 1
        [cust_group] => 0
        [price] => 32.0000
        [price_qty] => 6.0000
    )

[1] => Array
    (
        [price_id] => 8
        [website_id] => 0
        [all_groups] => 1
        [cust_group] => 0
        [price] => 31.0000
        [price_qty] => 12.0000
    )
like image 168
Ivaylo Alexandrov Avatar answered Nov 24 '22 06:11

Ivaylo Alexandrov


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()

like image 35
WonderLand Avatar answered Nov 24 '22 07:11

WonderLand