Tier Price offers the shoppers to shop a large amount of quantity of the specific item at a discountable rate.
Magento 2 allows tier prices based on the customer group. Customer Group may be All, Guest, Wholesaler, login, Retailer or any custom-defined. Tier Price is the way to give a different price structure for different customer groups.
Retrieve tier price of the product by customer group id in Magento 2 achieved by Magento\Catalog\Api\ScopedProductTierPriceManagementInterface.
<?php namespace Jesadiya\TierPrice\Model; use Magento\Catalog\Api\Data\ProductTierPriceInterface; use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface; class TierPrice { /** * @var ScopedProductTierPriceManagementInterface */ private $tierPrice; public function __construct( ScopedProductTierPriceManagementInterface $tierPrice ) { $this->tierPrice = $tierPrice; } /** * Get Tier price by the customer group * * @return ProductTierPriceInterface[] */ public function getTierPrice() { $sku = '24-MB02'; $customerGroupId = 1; //you can also define 'all' $tierPrice = $this->tierPrice->getList($sku, $customerGroupId); return $tierPrice; } }
You can define SKU and Customer group id to retrieve the list of tier prices of the specific customer groups.
You can see the Customer Group from the Admin Panel, Customers -> Customer Groups. Check the Customer group id from the grid.
echo $tierPriceData = $this->getTierPrice();
Output:
Array ( [value] => 30.000000 [qty] => 5.0000 [customer_group_id] => 1 ) Array ( [value] => 25.000000 [qty] => 10.0000 [customer_group_id] => 1 )