I'm writing a maintenance script to tidy up unused customer group tiered prices. How can I programatically get either: All products that have a tiered price for the selected customer group and then delete the tiered price for that group OR Check if a product has a tiered price for the selected customer group and then delete the tiered price for that group.

Bear in mind I don't know the quantity, only the group id so I can't use getTierPrice() as that needs a quantity.

How do I delete the tiered price? Can I just use setTierPrice() and set the price and quantity to 0?

$roleId = Mage::getSingleton('customer/session')->getCustomerGroupId();
$TierPrice = $product->getData('tier_price');
$customer_grouptier = array_column($TierPrice, 'price','cust_group');
$customer_tier = $customer_grouptier[$roleId]; 

$product is the product Object.

More information click below. Getting Current Customer Group Price, and Tier Price

| improve this answer | |

Go to magento admin > product manager > edit a producct > price tab, add price according to customer group, then use the below code to display the price according to customer group ID but you need to loged-in first a customer to check the customer ID

$now = Mage::getSingleton('core/date')->timestamp( time() );
$websiteId = Mage::app()->getStore()->getWebsiteId();
$customerGroup = 4; /* get logged-in customer group ID */

Mage::getResourceModel('catalogrule/rule')->getRulePrice( $now, $websiteId, $customerGroup, $_productId);

If you are in product listing OR detail page you can also use this code:

$product = Mage::getModel('catalog/product')->load($productId);

$groupPrices = $product->getData('group_price')

Enjoy! it will help you.

| improve this answer | |
  • Sorry but that doesn't seem to work. If I echo: $price = Mage::getResourceModel('catalogrule/rule')->getRulePrice( $now, $websiteId, $customerGroup, $_productId); it doesn't return anything – Denial Design Nov 23 '15 at 19:01
  • you have added price as per group from admin? – Surya prakash Patel Nov 24 '15 at 6:29
  • Yes, the tiered prices have been added. – Denial Design Nov 24 '15 at 10:38
  • Not Tire prices, add "Group Price" and then check again – Surya prakash Patel Nov 24 '15 at 11:14
  • I'm not using group prices, I'm using tiered pricing. – Denial Design Nov 24 '15 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.