views:

599

answers:

2

I have wholesale attributes for certain products under one store in Magento. I would like to set it so those particular attributes only appear on the product page IF the customer is logged in and they are in the Wholesale customer group.

Is this possible?

+3  A: 

Something like this should work, although I have not tested this together. It's assuming your wholesale groupid = 2 and that 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');
      }
    }

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

nvoyageur
Going to check this out, but it looks right-ish.
f8xmulder
That did not appear to work, unfortunately. Here's the latest code I've got: <?php $_isLoggedIn = $this->helper('customer')->isLoggedIn(); if($_isLoggedIn == true){ $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); if($_myGroupId == 2){ //echo $_helper->productAttribute($_product, $this->htmlEscape($_product->getNumPerBox()), 'number_per_box'); } } ?>I also edited Mage>Catalog>Model>Product.php to include a function but it returns an error.
f8xmulder
A: 

Okay, here's the solution.

In template/catalog/product/view> attributes.phtml use the following:

<?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>';
      }
    }
?>

Thanks to @nvoyageur for the initial pointer in the right direction!

f8xmulder
Glad to be of service... thanks for posting a final solution that really works.
nvoyageur