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 www.yourdomain.com/group-price.php. 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.

Previous Post

Manual cleaning magento database logs phpmyadmin

Next Post

New order email confirmation is not working in Magento 1.9


  1. Ashutosh Pandey says:

    I am not able to save the group price. code just deleted any previous group price but did not update new group price

    1. Ashutosh Pandey says:

      I fixed this issue. But got new issue.. I want to update existing group price without deleting previous group price. it should match group price and if there is group price present then do nothing else it should update it

      1. Webpioneer says:

        Hey Ashutosh,

        Above post is for updating group price, if you want your way you can customise using a condition before update.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top