我试图在magento 1.8中制作自定义产品类型,一切正常但是在将产品添加到购物车时出现此错误:Class' Zend_Log'在...... / Dmx / Plate / Model / Product / Type / Plate.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;
}
}
所以我无法弄清楚我做错了什么。
答案 0 :(得分:0)
Donot在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>