IT insight blog

Boost IT troubleshooting

Update customer group price programmatically Magento

Update group price in magento

Some time its very difficult to update all products group price individually from admin of magento. Today i will show how to update it programmatically simultaneously.

group price

require_once 'app/Mage.php';

$file = 'group-price.csv';
$csv = new Varien_File_Csv();
$data = $csv->getData($file);

foreach ($data as $value) {
$sku = $value[0];

$product = Mage::getModel('catalog/product')->setStoreId(0)->load(Mage::getModel('catalog/product')->getIdBySku($sku));

if ($product == false || !$product->getSku()) {

//delete existing records if any

//create array for new customer price group
$new_price = array(
array ('website_id'=>0, 'cust_group'=>$value[1], 'price'=>$value[2]),
array ('website_id'=>0, 'cust_group'=>$value[3], 'price'=>$value[4])
//Add new customer group price
$product->setData('group_price', $new_price);

echo "Group price update successfully.";


1. Create an excel file and save as “group-price.csv” or any you wish.
2. IMP: on first row in sheet “sku” column name should be there, as shown in image. and remaining column you can give any name.
3. Upload csv file to root path of magento on server.
4. Create a file “group-price.php” and add code as shown above and upload to root of magento.
5. Run the url Voila!! all the products group price updated. You can check in any Product > Price tab there you will see two price with base price.

Here important point to remind you can use the website_id, storeid for which products you are going to update.

« »

© 2017 IT insight blog.