0

I'd like to display a products group price for a specific customer group (group id 5) for non logged in users to show the savings for a membership on a product page.

Example:

Not Logged in Customer Price: 100$

Member Subscription Price: 65$

Cant find anything like this other than an old SE question that I cant get the code to work: https://stackoverflow.com/questions/12326814/magento-get-product-price-given-a-customer-group

SR_Magento
  • 5,209
  • 13
  • 62
  • 103

1 Answers1

2

If you want to show all group price then you need to call group_price attribute resource model $attribute = $ProductObject->getResource()->getAttribute('group_price') of that particular product

and using afterLoad() ($attribute->getBackend()->afterLoad($ProductObject)) You will get group prices value in array of a particular product which include group price and respective customer group id

You can use

$groupPrices = $ProductObject->getData('group_price');
$Groupprice= $groupPrices;
    if (is_null($groupPrices)) {
        $attribute = $ProductObject->getResource()->getAttribute('group_price');
        if ($attribute){
            $attribute->getBackend()->afterLoad($ProductObject);
            $groupPrices = $ProductObject->getData('group_price');
        }
    }
    /* check group price exit nor not */
     if (!is_null($groupPrices) || is_array($groupPrices)) {

        foreach ($groupPrices as $groupPrice) {
        if($groupPrice['cust_group']=='Member_Subscription_Id'):
            // Customer id match &  group price show

            echo $Groupprice = $groupPrice['website_price'];
            echo $GroupId=$groupPrice['cust_group'];
            $formated_price = Mage::app()->getStore()->formatPrice($Groupprice);
                    $formated_price_incl_tax = Mage::app()->getStore()->formatPrice(
                        Mage::app()->getStore()->convertPrice(
                            Mage::helper('tax')->getPrice($ProductObject, $Groupprice, true)
                        )
                    );
        endif;          
        }
    }

Another Example: https://magento.stackexchange.com/a/36216/4564

Amit Bera
  • 77,456
  • 20
  • 123
  • 237
  • Will this be able to target a specific customer group for group price? I want to show the group price for customer group id 5 to everyone – SR_Magento Jan 01 '16 at 16:56
  • yes,you can do as =$groupPrice['cust_group'] give customer id – Amit Bera Jan 01 '16 at 17:01
  • did u get result – Amit Bera Jan 01 '16 at 17:57
  • this code did not work. I checked and it looks like youve answered several similar questions with the same code (excluding the one you linked). Would really appreciate if you could double check. I just want to show 1 specific group price on all product pages. So when non members visit the page they will see the "group price". I dont need anything else, the idea is just to display this price. – SR_Magento Jan 02 '16 at 00:27