Here's a quick approach to hack it to work, i use grouped & associated simple products so this may not work with configurable ones. But could easily enough be made too.
In this example the Trade group is 4 & the adjustment is /0.8
in: app/code/core/Mage/Catalog/Model/Product/Type/Price.php
make function getFinalPrice look like this:
/**
* Get product final price
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty=null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
//haydent
$gId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($gId != 4 ){
$product->setPrice($product->getPrice() / 0.8);
}
//haydent
$finalPrice = $product->getPrice();
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product'=>$product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return max(0, $finalPrice);
}
and function getTierPrice look like this:
/**
* Get product tier price by qty
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getTierPrice($qty = null, $product)
{
$allGroups = Mage_Customer_Model_Group::CUST_GROUP_ALL;
$prices = $product->getData('tier_price');
//haydent
$gId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($gId != 4 ){
foreach($prices as $index => $value){
$prices[$index]['price'] = $prices[$index]['price'] / 0.8;
$prices[$index]['website_price'] = $prices[$index]['website_price'] / 0.8;
}
}
//haydent
if (is_null($prices)) {
$attribute = $product->getResource()->getAttribute('tier_price');
if ($attribute) {
$attribute->getBackend()->afterLoad($product);
$prices = $product->getData('tier_price');
}
}
if (is_null($prices) || !is_array($prices)) {
if (!is_null($qty)) {
return $product->getPrice();
}
return array(array(
'price' => $product->getPrice(),
'website_price' => $product->getPrice(),
'price_qty' => 1,
'cust_group' => $allGroups,
));
}
$custGroup = $this->_getCustomerGroupId($product);
if ($qty) {
$prevQty = 1;
$prevPrice = $product->getPrice();
$prevGroup = $allGroups;
foreach ($prices as $price) {
if ($price['cust_group']!=$custGroup && $price['cust_group']!=$allGroups) {
// tier not for current customer group nor is for all groups
continue;
}
if ($qty < $price['price_qty']) {
// tier is higher than product qty
continue;
}
if ($price['price_qty'] < $prevQty) {
// higher tier qty already found
continue;
}
if ($price['price_qty'] == $prevQty && $prevGroup != $allGroups && $price['cust_group'] == $allGroups) {
// found tier qty is same as current tier qty but current tier group is ALL_GROUPS
continue;
}
if ($price['website_price'] < $prevPrice) {
$prevPrice = $price['website_price'];
$prevQty = $price['price_qty'];
$prevGroup = $price['cust_group'];
}
}
return $prevPrice;
} else {
$qtyCache = array();
foreach ($prices as $i => $price) {
if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroups) {
unset($prices[$i]);
} else if (isset($qtyCache[$price['price_qty']])) {
$j = $qtyCache[$price['price_qty']];
if ($prices[$j]['website_price'] > $price['website_price']) {
unset($prices[$j]);
$qtyCache[$price['price_qty']] = $i;
} else {
unset($prices[$i]);
}
} else {
$qtyCache[$price['price_qty']] = $i;
}
}
}
return ($prices) ? $prices : array();
}
you should never call save
without calling load
first on a product instance.
A save
without a load (on a product from a collection for example) will lead to loss of data.
If you only want to update a single attribute value for a product do this:
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($attributeId),
array('attribute_code' => 'attribute_value'),
$storeId
);
$storeId
is the storeview for which you want to update the value. For default values use 0
.
Best Answer
If it's just an occasional operation and you don't need to automate it just do:
And do full reindex afterwards.