Magento 2 – Set Tier Price Programmatically, Issue with Unchecked Default Store View

magento2store-viewtierprice

Before I set in admin like below

enter image description here

After I execute script to update tier price for same product it changes as like below which is issue

enter image description here

Code I use to set tier price is below

    $tierPrices[] = [
        'cust_group' => 17,
        'price' => 16.57,
        'website_id' => 0,
        'price_qty' => 5,
   ];
  $product = $this->productRepository->get($sku, ['edit_mode' => true]);
  $product->setData('tier_price', $tierPrices);
  $this->productRepository->save($product);

Best Answer

I found this was magento bug which is resolved in 2.4.2+

https://github.com/magento/magento2/issues/26484

Related Topic