We have more then 50000 products in our website and i want update tier price for existing website. I have added code for update tier price for 4 customer groups. and it is working for 500 to 600 products. but when i want all products tier price then it is showing 500 error. please give me solution or how to use callback function in magento2 so that i can update products tier price I have used code like and it is working 500 to 600 products limit
use \Magento\Catalog\Api\ProductTierPriceManagementInterface;
include('app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
$productcollection = $productCollection->addAttributeToSelect('*')->setOrder('entity_id','ASC')->setPageSize(800)->load();;
$i=1;
$tierPrice= array();
foreach ($productcollection as $product)
{
$p_id = $product->getId();
$p_price = $product->getPrice();
if($p_price >0)
{
$newPrice1=($p_price /2.5)*2;
$newPrice2=($p_price /2.5)*1.8;
$newPrice3=($p_price /2.5)*1.6;
$newPrice4=($p_price /2.5)*1.4;
$productRepository = $objectManager->get('\Magento\Catalog\Model\ProductRepository');
$productObj = $productRepository->getById($product->getId());
$tierPrice[0] = array('website_id' => 0,'cust_group' => 5, 'price_qty' => 1 , 'price' => $newPrice1);
$tierPrice[1] = array('website_id' => 0,'cust_group' => 6, 'price_qty' => 1 , 'price' => $newPrice2);
$tierPrice[2] = array('website_id' => 0,'cust_group' => 7, 'price_qty' => 1 , 'price' => $newPrice3);
$tierPrice[3] = array('website_id' => 0,'cust_group' => 8, 'price_qty' => 1 , 'price' => $newPrice4);
// $productObj->setPrice(103.59);
$productObj->setTierPrice($tierPrice);
$productObj->save();
echo "Price Updated for Product Id : " . $p_id."</br>";
echo"Product count number " . $i."<br/>";
}
$i++;
} ```