I have below snippet which I am using to update tier prices programaticaly:

$tierPricenew[0] = array('website_id' => 2,'cust_group' => $groupId, 'price_qty' => 1 , 'price' => floatval($price) );
$prices = $productObj->getTierPrice();

This however takes very long with lots of products and so want to just update the tier_price attribute alone as suggested elsewhere on stack exchange to quicken the whole process rather than saving the whole product object.

I have tried below methods saveAttribute:

$tierPricenew[0] = array('website_id' => 2,'cust_group' => $groupId, 'price_qty' => 1 , 'price' => floatval($price) );
$prices = $productObj->getTierPrice();
$productObj->setData('tier_price', $prices);
$this->productResource->saveAttribute($productObj, 'tier_price');

And this method updateAttributes:

$tierPricenew[0] = array('website_id' => 2,'cust_group' => $groupId, 'price_qty' => 1 , 'price' => floatval($price) );
$prices = $productObj->getTierPrice();
$this->productResourceModel->updateAttributes([$productObj->getId()], ['tier_price' => $prices]);

None of the above however seem to work for me. No errors are thrown however tier prices are not set. They work with other attributes like name etc but not tier_prices. Is there a way to update these quickly with methods like above?

I have looked into the Magento\Catalog\Api\ProductTierPriceManagementInterface class and tried with the remove method here however looking at this just seems to do very similar to my first method and saves the complete product object.

$this->tierPrice->remove($product->getSku(), $groupId, '1');

Import seems to do this so fast so feel there must be a quicker method to use here.


I think this should work for you.

namespace Test\Sample\Controller\Index;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Catalog\Api\ProductTierPriceManagementInterface;

class Index extends Action

    protected $tierPrice;

    public function __construct(Context $context, ProductTierPriceManagementInterface $tier)
        $this->tierPrice = $tier;

     public function execute()
        $sku = 'test-sku'; //Product sku
        $customerGroupId = 2; //Wholsaler group id
        $price = 200;
        $qty = 55;

        $this->tierPrice->add($sku,$customerGroupId,$price, $qty);

I found the answer at this location Magento 2: How to set Tier Pricing Programatically Group Wise

  • This isn't fast. Takes 1 sec to update 1 price atleast in my env. Which is quite slow. Nov 25 '21 at 14:31

Magento 2 provides Dataflow for importing/exporting Tier pricing by default. But it has to be imported separately. Also, it's very slow as it operates one by one on the data.

If you want to update regular price along with special, tier & customer group price, you can use this extension for Magento 2:
Magento 2 Regular, Special & Tier Price Importer

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.