Currently I have a custom API to live feed the product tier prices with data like this:
[
{
"sku":"X772A5",
"customer_group_id":"1",
"website_id":"2",
"qty":"5",
"price":"500"
},
{
"sku":"X772A5",
"customer_group_id":"2",
"website_id":"2",
"qty":"2",
"price":"450"
},
{
"sku":"X772A5",
"customer_group_id":"1",
"website_id":"1",
"qty":"5",
"price":"490"
},
{
"sku":"X8911V",
"customer_group_id":"2",
"website_id":"1",
"qty":"2",
"price":"120"
}
]
The data contains the product ski , customer group ID, website ID, product qty for the tier price, and product price. I want to remove all the product tier prices and then I can insert this new tier prices data, how can I achieve this?
public function execute(){
$datas = $this->getInputDatas();
$this->removeTierPrices($datas);//???
foreach($datas as $data){
$product = $this->getProductBySku($data['sku']);
$this->addTierPrice($product,$data);//??
}
}