2010-02-09 130 views

回答

6

这样的东西应该可以工作,虽然我没有一起测试过。这是假设您的批发GROUPID = 2,要展示的产品属性 '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

+0

要检查这一点,但它看起来是正确的。 – f8xmulder 2010-02-10 07:57:20

+0

不幸的是,这似乎并不奏效。这里是我得到的最新代码: <?php \t \t $ _isLoggedIn = $ this-> helper('customer') - > isLoggedIn(); if($ _ isLoggedIn == true){____GroupId = Mage :: getSingleton('customer/session') - > getCustomerGroupId(); if($ _ myGroupId == 2){echo $ _helper-> productAttribute($ _ product,$ this-> htmlEscape($ _ product-> getNumPerBox()),'number_per_box'); } } ?> 我还编辑了Mage> Catalog> Model> Product.php来包含一个函数,但它返回一个错误。 – f8xmulder 2010-02-10 16:00:29

2

好吧,这里的解决方案。

在模板/目录/产品/视图> 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用于在正确的方向的初始指针!

+0

很高兴能为您提供服务......感谢您发布真正有效的最终解决方案。 – 2010-02-11 22:05:23

0

我有相同的使用案例,我用GroupsCatalog扩展,这是免费的,并为我完美的作品。

+0

链接重定向到Magento Commerce主页。 – NotJay 2015-09-01 20:14:19

+0

我明白了!无论是扩展已被停用或其[本](http://www.magentocommerce.com/magento-connect/paymentfilter-for-products-and-customer-groups.html)之一。 – 2015-09-02 05:08:25

相关问题