首页 文章

Magento定制产品类型'Zend_Log'未找到

提问于
浏览
0

我正在尝试在magento 1.8中制作自定义产品类型,一切正常但是在将产品添加到购物车时我收到此错误:在'/ Dmx / Plate / Model / Product / Type / Plate中找不到类'Zend_Log' .php在第23行 .

class Dmx_Plate_Model_Product_Type_Plate extends Mage_Catalog_Model_Product_Type_Abstract{

    protected $_isComposite = false;
    protected $_canConfigure = true;

    protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode){
        $preparedProduct = parent::_prepareProduct($buyRequest, $product, $processMode);
        $preparedProduct = $preparedProduct[0];
        $preparedProduct->setPrice(10);

        return array($preparedProduct);
    }

    public function hasRequiredOptions($product = null){
        return true;
    }

    public function hasOptions($product){
        return true;
    }
}

所以我无法弄清楚我做错了什么 .

1 回答

  • 0

    不要在Plate.php做任何事情,请从这里删除价格代码

    <?php
    class Dmx_Plate_Model_Product_Type_Plate extends Mage_Catalog_Model_Product_Type_Abstract{
    
        protected $_isComposite = false;
        protected $_canConfigure = true;
    
        protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode){
                    return parent::_prepareProduct($buyRequest, $product, $processMode);
        }
    
        public function hasRequiredOptions($product = null){
            return true;
        }
    
        public function hasOptions($product){
            return true;
        }
    }
    

    调用该模型的price.php

    <?php 
    class Dmx_Plate_Model_Product_Type_Plate_Price extends Mage_Catalog_Model_Product_Type_Price
    {
         protected function _applyOptionsPrice($product, $qty, $finalPrice)
        {
                $basePrice = $finalPrice;
                //$finalPrice=785;
                 /*
                if($product->getCustomOption('card_amount'))
                {
                 $giftcartprice=$product->getCustomOption('card_amount')->getValue();
                $curretCurrency=Mage::app()->getStore()->getCurrentCurrencyCode();
                $baseCurrency=Mage::app()->getStore()->getBaseCurrency();
                $cardCurrency = Mage::getModel('directory/currency')->load($curretCurrency);
                $currentRadio=$baseCurrency->getRate($cardCurrency);
                $finalGiftcartdPrice=$giftcartprice;
                if($currentRadio)
                {   
                $finalGiftcartdPrice=$giftcartprice/$currentRadio;
                }
               foreach (explode(',', $optionIds->getValue()) as $optionId) {
                    if ($option = $product->getOptionById($optionId)) {
                        $confItemOption = $product->getCustomOption('option_'.$option->getId());
    
                        $group = $option->groupFactory($option->getType())
                            ->setOption($option)
                            ->setConfigurationItemOption($confItemOption);
                        $finalPrice += $group->getOptionPrice($confItemOption->getValue(), $basePrice);
                    }
                }
                $finalPrice+=$finalGiftcartdPrice;
                }*/
            return $finalPrice;
            return 10;
        }
    
    }
    ?>
    

    需要为板材产品添加价格模型文件 <price_model>plate/product_type_plate_price</price_model>

    应该添加编辑config.xml

    <catalog>
            <product>
                <type>
                    <plate translate="label" module="plate">
                        <label>Plate</label>
                        <model>plate/product_type_plate</model>
                        <price_model>plate/product_type_plate_price</price_model>
                         <index_data_retreiver>plate/catalogindex_data_plate</index_data_retreiver>  
                        <is_qty>1</is_qty>
                         <composite>0</composite>
                    </plate>
                </type>
            </product>
        </catalog>
    

相关问题