Magento has strong features to set Tier price. If you are interested to set multiple prices of a product for combination of customer group and product quantities, you can set by Magento Tier price option.
We can handle tier price in many ways. Here I am describing basic logic to add/update tier price in modular way. At first define all tier prices as an array. Ofcourse mind one thing about quantity. Quantity format must be four decimal precision. Like 100.0000. For this you can use below formatting.
$qty = number_format($qty, 4, ‘.’, ”);
02 | $tierPrices [] = array ( |
04 |
'cust_group' => $customer_group_id , |
10 | $tierPrices [0] = array ( |
13 |
'price_qty' => 100.0000, |
17 | $tierPrices [1] = array ( |
20 |
'price_qty' => 100.0000, |
25 | $productid = Mage::getModel( 'catalog/product' ) |
29 | $product = Mage::getModel( 'catalog/product' ); |
32 | $product ->load( $productid ); |
35 | $existingTierPrice = $product ->tier_price; |
38 | $tierPrices = array_merge ( $existingTierPrice , $newTierPrices ); |
41 | $product ->tier_price = $tierPrices ; |
Also Magento has web service API support to handle tier price. If you are expert in web service work then you can do the same thing using Magento API. To handle tier price with api call do something like below.
02 | $sessionId = $proxy ->login( 'apiUser' , 'apiKey' ); |
05 | $tierPrices = $proxy ->call( $sessionId , 'product_tier_price.info' , 'Sku' ); |
08 | $tierPrices [] = array ( |
10 |
'customer_group_id' => 'all' , |
16 | $proxy ->call( $sessionId , 'product_tier_price.update' , array ( 'Sku' , $tierPrices )); |