Question

I have a strange one.

I took a new install of magento, and a new theme and connected them to an existing magento website db.

When I log to my account as 'dealer' I can go to the homepages and interior pages and I am a dealer and can see my pricing.

As soon as I enter the cart my customer group is shown as the default group and not 'dealer', if I go back into the product pages I can see I am a dealer again.

Any clue to what in the world is going on?

I am using this to show my group:

<?
if(Mage::getSingleton('customer/session')->isLoggedIn()){
      // Get group Id
      $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
      //Get customer Group name
      $group = Mage::getModel('customer/group')->load($groupId);
      echo $group->getCode();
}
?>

If you want to test you can create an account here and it will set you as 'Dealer'.

http://tinyurl.com/mqufujc

You can see it show the customer group on the top left if you are logged in.

I tried adding this at the top of the head.phtml and although it echoed the correct customer_group it did not solve the issue with the prices rendering incorrectly.

if(Mage::getSingleton('customer/session')->isLoggedIn()){
      // Get group Id
    $customerz = Mage::getSingleton('customer/session')->getCustomer();
    $email = $customerz->getEmail();
    $customerz->loadByEmail($email); //load customer by email id
    $newGroupId = $customerz->getGroupId(); 
    $customerz->setGroupId($newGroupId)->save();
}

I have uploaded all of the files from a fresh magento install app/code/core.

I have tried with the default theme and without and no change.

SOLVED

Thank you for your help, it was the Automatic Group Assignment issue.

This is a great module that I am using for the advanced login with automatic customer group assignment and custom fields. http://www.magentocommerce.com/magento-connect/registration-form-advanced.html

Was it helpful?

Solution

Because you're calling function getCode() with empty value – which's returning defualt group while you should call getCode($VALUE) – which's in your case $groupId which you've loaded one line above.

You have a mistake at line:

  echo $group->getCode();

while it should be:

  echo $group->getCode($groupId);

Change your code into:

<?php
if(Mage::getSingleton('customer/session')->isLoggedIn()){
      // Get group Id
      $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
      //Get customer Group name
      $group = Mage::getModel('customer/group')->load($groupId);
      echo $group->getCode($groupId);
}
?>

Have a nice weekend,
versedi

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top