Magento – magento2 how to update tier price programmatically, including value type

magento2tierprice

I am able add tier prices using csv

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

but it is taking "value_type" as Fixed , i want to dynamically give the value for "value_type"

Best Answer

I done the same by doing

$product_obj = $this->_objectManager->create('Magento\Catalog\Model\Product')->load($prod_id);
    $tierPrices[] = array(
                                 'website_id'  => 0,
                                 'cust_group'  => 1,
                                 'price_qty'   => $qty,
                                 'price'       => $price,
                                 'percentage_value'  => $percentage);
                          $product_obj->setTierPrice($tierPrices);
                        $product_obj->save(); 
Here in the above array   `percentage_value` is given for the price range having discount type.         
Related Topic