隐藏未登录的级别价格 - 目录权限扩展Magento

时间:2014-08-26 14:29:51

标签: php magento

我正在使用aheadWorks的目录权限扩展来隐藏未登录的客户的价格。但是,我还需要能够隐藏层定价。 PHP代码将用于什么以及我将它放入哪个文件?

3 个答案:

答案 0 :(得分:0)

层级定价很好,但您不希望向每个客户显示每个价格。要仅向登录的访问者显示分层定价,请转到:app/design/frontend/default/default/template/catalog/product/view/tierprices.phtml

在此文件中,添加此PHP函数

<?php if(Mage::getSingleton('customer/session')->isLoggedIn()):

上面的函数应该在下面的代码之前添加

<?php if (count($_tierPrices) > 0): ?>

然后在最后添加此代码。

<?php endif; ?>

答案 1 :(得分:0)

创建您自己的布局文件,并在里面设置您自己的模板文件,其中包含所需的条件。

   <catalog_product_view>
       <reference name="core_reference_name">
          <action method="setTemplate">
            <template>yournamespace/catalog/product/view.phtml</template>
            </action>
        </reference>      
   </catalog_product_view>

答案 2 :(得分:0)

在类别列表页面,产品视图页面和比较弹出窗口中隐藏价格。 用基本模块覆盖默认的Magento文件。

为基本模块Hideproductprice

创建文件夹和文件
app/etc/modules/Hideproductprice_Hideproductprice.xml
app/code/local/Hideproductprice/Hideproductprice/controllers/IndexController.php
app/code/local/Hideproductprice/Hideproductprice/etc/config.xml
app/code/local/Hideproductprice/Hideproductprice/Block/Index.php

app/design/frontend/base/default/layout/hideproductprice.xml
app/design/frontend/base/default/template/hideproductprice/price.phtml

1:将以下代码添加到自定义模块布局文件

(app/design/frontend/base/default/layout/hideproductprice.xml)
<default>
        <reference name="catalog_product_price_template">
            <action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
            <action method="addPriceBlockType"><type>grouped</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
            <action method="addPriceBlockType"><type>configurable</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
            <action method="addPriceBlockType"><type>virtual</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
            <action method="addPriceBlockType"><type>bundled</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
        </reference>
  </default>

2:然后复制默认的'price.phtml'并将其放在指定位置(在我们的例子中为'hideproductprice / price.phtml')。并将以下代码置于其上。

<?php
    if(!Mage::getSingleton('customer/session')->isLoggedIn()){
        echo '<span class="login_for_price"><b>Login to See Price</b></span><br>';
        return;
    }
    ?>

Mage_Adminhtml_Block_Orders_Grid

/* adding customer name section */       
        $customerFirstNameAttr = Mage::getSingleton('customer/customer')->getResource()->getAttribute('firstname');
        $collection->getSelect()
                            ->joinLeft(
                                array('cusFirstnameTb' => $customerFirstNameAttr->getBackend()->getTable()),
                                'main_table.customer_id = cusFirstnameTb.entity_id AND cusFirstnameTb.attribute_id = '.$customerFirstNameAttr->getId(). ' AND cusFirstnameTb.entity_type_id = '.Mage::getSingleton('customer/customer')->getResource()->getTypeId(),
                                array('customer_name' =>'cusFirstnameTb.value')
                            ); 
            /* end adding customer name section */
相关问题