Display custom product attributes based on customer group (Magento)

I have wholesale attributes for certain products in one Magento store. I would like to set it so that these specific attributes are displayed only on the product page if the customer is logged in and they are in the group of wholesale buyers.

Is it possible?

+5
source share
3 answers

Something like this should work, although I have not tested it together. It assumes your wholesale groupid = 2 and you want to show the product attribute 'productvideos'

app / design / frontend / default // template / catalog / product / view.phtml
    if($_isLoggedIn === true){
      $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();          
      if($_myGroupId == 2){
        print $_helper->productAttribute($_product, $_product->getProductvideos(), 'productvideos');
      }
    }

: http://www.magentocommerce.com/boards/viewthread/22597/#t74992

+6

, .

/// > attributes.phtml :

<?php       
    $_isLoggedIn = $this->helper('customer')->isLoggedIn();
    if($_isLoggedIn == true){
      $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();          
      if($_myGroupId == 2){
        echo '<td class="label">Attribute Name/Label</td>';
        echo '<td class="label">';
        if ($_product->getResource()->getAttribute('attribute_id')->getFrontend()->getValue($_product)):
          echo $_product->getResource()->getAttribute('attribute_id')->getFrontend()->getValue($_product);
        endif;
        echo '</td>';
      }
    }
?>

@nvoyageur !

+2
0

All Articles