doubang4881 2013-07-17 08:19
浏览 22

在magento 1.7中显示最低广告价格而不是价格

Once again thanks for viewing this post i would like to mention that i need a requirement of map price in magento what actually i need . I am having some product which have MAP price and also price , so on listing of product if map price is available then system will show map price because vender cant sell below the map price,

Example: MAP: $3 Price : $2 Then System Will Show MAP Price Of Product in this case.

Do i need to override core functionality for catalog price product rule or is there anyway to show that map price on .phtml file. If i do condition on price in phtml file will it get affected on all like in cart and detail pages. or do i need to make changes on everywhere. If i want to override the rule then in which file i need to change

And do MAP Configuration but it show price on everywhere on cart to am i doing wrong with MAP configuration.

Please help me Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dsnd7200 2013-07-17 09:59
    关注

    Adding a condition inside your template (phtml) file would cause issues for you. This price would be shown to the visitor, but the actual price field would be used in calculations / cart etc so there could be a mismatch.

    The simplest way to do what you want would probably be to override the Product model and/or Product Price Model.

    Mage_Catalog_Model_Product
    Mage_Catalog_Model_Product_Type_Price
    

    there's a load of guides on how to override models:

    http://magento4u.wordpress.com/tag/override-catalog-product-model/
    

    For simplicity you could just copy the class into the local namespace which would override the class without having to create a module/xml etc.

    class Mage_Catalog_Model_Product_Type_Price
    {
        /**
         * Default action to get price of product
         *
         * @return decimal
         */
        public function getPrice($product)
        {
            if($product->getMsrp() > $product->getData('price')) {
                return $product->getMsrp();
            }
    
            return $product->getData('price');
        }
    }
    

    Something like that might do the trick, although it;s not tested in anyway shape or form but it might help get you started..

    or override the getPrice method inside the product class

    Mage_Catalog_Model_Product

    /**
     * Get product price throught type instance
     *
     * @return unknown
     */
    public function getPrice()
    {
        if ($this->_calculatePrice || !$this->getData('price')) {
            $price = $this->getPriceModel()->getPrice($this);
        } else {
            $price = $this->getData('price');
        }
    
        if($this->getMsrp() > $price) {
            return $this->getMsrp();
        }
    
        return $price;
    }
    

    You can see sometimes it may not be using the price model, so it may be better to override the getPrice method in the product class.. try it out.

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序