根据客户组显示自定义产品属性 (Magento)

发布于 2024-08-21 00:49:56 字数 91 浏览 1 评论 0原文

我在 Magento 的一家商店下拥有某些产品的批发属性。我想将其设置为仅当客户登录并且属于批发客户组时,这些特定属性才会显示在产品页面上。

这可能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

粉红×色少女 2024-08-28 00:49:57

我有相同的用例,并且使用了 GroupsCatalog 扩展,这是免费的并且非常适合我。

I had the same use case and I used the GroupsCatalog extension, which is free and works perfectly for me.

记忆で 2024-08-28 00:49:56

像这样的东西应该可以工作,尽管我还没有一起测试过。假设您的批发 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

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

温折酒 2024-08-28 00:49:56

好的,这是解决方案。

在模板/目录/产品/视图>中attribute.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 提供了正确方向的初始指针!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文