1

I have look for this in google, bing and magento.stackexchange and see nothing about it.

We have a situation: we have make a new attribute in admin and we want this attribute to be visible on front end but only for one type of customer groups and not all.

Can anyone have a solution or maybe module?

Thanks!

1 Answer 1

2

A simple Google-search ("magento product attribute via customer group") reveals that this question has been asked before on stackoverflow.

"Displaying custom product attributes based on customer group (Magento)"

Summarized: In the view (probably app/design/frontend/default//template/catalog/product/view.phtml) you want to have this logic, use the following code:

$_isLoggedIn = $this->helper('customer')->isLoggedIn();

if ($_isLoggedIn == true){
    $_groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();          

    if ($_groupId === 'X') {
        // output your product attribute
    }
}

X being the customer group the attribute should be shown for. Because having scattered random ID's like these in view files is (in my personal opinion) a bad practice, you probably want to abstract that away a bit so you can easily modify the product attributes related to a specific customer group.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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