7

As we use in :

/opt/lampp/htdocs/magento_composer/vendor/magento/module-catalog/view/base/templates/product/price/tier_prices.phtml

How can i use getTierPriceList() in my custom module's template file ?

also is it available in product collection ?

I tried a lot but is unable to load product collection as we used to do in magento 1.x.

Tried:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load(2);

in this

$product->getPrice();

is working but how can i get tierprice in template file? i.e. my main concern.

1 Answer 1

6

You can get the tier price by below code.

$tierPrices = [];

$tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();

foreach ($tierPricesList as $tierPrice) {
    $tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
}

For more details observe the core module code.

\vendor\magento\module-catalog\Block\Product\View.php

Hope this helps.

3
  • Getting Blank page every time .. Commented Sep 6, 2016 at 12:33
  • Check the error log, it will work and refer the code in the mentioned file. Commented Sep 6, 2016 at 12:35
  • Hi @krishnaijjadaati95Dev how to get this info in Magento_Catalog\templates\product\price\final_price.phtml?
    – Jackson
    Commented Nov 9, 2016 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.