3

I would like to display all customer group price for that product on product detail page.

May be need to work on vendor\magento\module-catalog\view\base\templates\product\price\final_price.phtml

So when user is not logged in they are able to see for this Group we have this prices.

$productId = $block->getSaleableItem()->getId(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $ProductObject = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); $groupPrices = $ProductObject->getData('group_price'); echo "<pre>"; print_r($groupPrices); exit; 

After that, need to set Customer Group wise Promotion Price, then also display that.

1 Answer 1

4

Below is the way to get

/** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $block */ $productId = $block->getSaleableItem()->getId(); // START $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $_product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); $productAllTierPrices = $_product->getData('tier_price'); $allTierPrices = array(); foreach($productAllTierPrices as $tierPrices){ $groupname = $objectManager->create('Magento\Customer\Model\Group')->load($tierPrices['cust_group'])->getCustomerGroupCode(); $allTierPrices[$groupname] = $tierPrices['price']; } echo "<pre>"; print_r($allTierPrices); exit; // END 

How to avoid ObjectManager in above code? If you know then can update the answer or post own.

Thanks

3
  • I have had success passing the "Registry" into my block class and accessing the current product from there. See thread: How do I get the current product in Magento2? Commented Apr 4, 2017 at 15:05
  • @Ankit, how can we get product price from the customer group Commented Feb 27, 2019 at 12:59
  • This does not work if the prices are set from Catalog rule. can anyone suggest on that? Commented Apr 23, 2019 at 13:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.