I am Using Magento 1.9.1.0 CE. Now I need to display or get the current group groupprice and Tier Price. I have google it, Most of the answer Related to ver 1.7 Magento .but its not resolving the Magento 1.9.1.0 or Need to check whether Tier Price and Group Price set the particular Customer Group.
Magento 1.9 – Getting Current Customer Group Price and Tier Price
group-pricemagento-1.9pricetiered-pricingtierprice
Related Solutions
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();
}
$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
Best Answer
Here
$product
is the product Object.Group Price:-
Here the current customer Group ID $roleId. $customer_groupprice is the customer Group Price.
Tier Price:-
Below the Conditions to check whether the Tier and Group Price Set or not