Skip to content

Instantly share code, notes, and snippets.

@willboudle
Created January 13, 2014 01:22
Show Gist options
  • Select an option

  • Save willboudle/8393197 to your computer and use it in GitHub Desktop.

Select an option

Save willboudle/8393197 to your computer and use it in GitHub Desktop.
Update Customer Group Price
<?php
// USAGE http://www.site.com/dev/updategroupprice.php?price=14.95&sku=ABC152X
require_once '../app/Mage.php';
umask(0);
//Mage::app('admin');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$sku = $_GET['sku'];
$id = $_GET['id'];
$price = $_GET['price'];
// get my product
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
// the group data is expecting an array of arrays that look like..
// array ('website_id'=>y, 'cust_group'=>z, 'price'=>n)
$groupPricingData = array (
// for website 2, customer group 2
array ('website_id'=>2, 'cust_group'=>2, 'price'=>$price),
);
$product->setData('group_price',$groupPricingData);
$product->save();
echo $sku." wholesale price has been updated to ". $price;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment