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.

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

  • 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? – nshiff Apr 4 '17 at 15:05
  • @Ankit, how can we get product price from the customer group – jafar pinjar Feb 27 at 12:59
  • This does not work if the prices are set from Catalog rule. can anyone suggest on that? – Tejas Vyas Apr 23 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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