How to get tier price of the product in Magento 2 with custom code?
This is my code
public function getProductCollection()
{
$collection = $this->_productCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->setOrder('created_at', 'DESC');
// $collection->setPageSize(3); // fetching only 3 products
return $collection;
}
and my call function in .phtml
$productCollection = $block->getProductCollection();
$productCollection->setPageSize(2);
foreach ($productCollection as $product) {
echo $product->getName();
print_r($product->getTierPrice());
echo getName ,getPrice,getSpecial price works
but getTierPrice is not working.
ex. I have VIP member card (customer_group) I want to show tier price VIP member card to public not set all group
Best Answer
You can get the TierPrice as below.
$product_obj
have a product data please check or debut it you can know. It will work 100%. see my log pic below.Create constructor in your class and initiate the class object. From that Object you can do stuff.