【发布时间】:2014-01-06 12:11:50
【问题描述】:
我已经定义了价格值的产品,如果我没有为该产品提供特价,我想使用某些属性显示价格和特价以外的其他价格。
当用户将产品添加到购物车时,这个新价格应该应用于产品。
如果可以,这在 magento 中是否可行,我该如何实现?
更新:
config.xml
<?xml version="1.0"?>
<config>
<modules>
<New_Price>
<version>1.0.0</version>
</New_Price>
</modules>
<global>
<models>
<price>
<class>New_Price_Model</class>
</price>
</models>
<events>
<checkout_cart_product_add_after>
<observers>
<price>
<type>singleton</type>
<class>New_Price_Model_Observer</class>
<method>priceTocart</method>
</price>
</observers>
</checkout_cart_product_add_after>
</events>
</global>
</config>
\app\code\local\Sigma\New\Model\Observer.php
Observer.php
class New_Price_Model_Observer extends Mage_Core_Model_Abstract
{
public function priceTocart($observer)
{
Mage::log("hello",null,"pricelog.txt");
$quoteItem = $observer->getData();
foreach($quoteItem as $cartItem)
{
echo $cartItem->getId()."<br>";
echo $cartItem->getSpecialPrice()."<br>";
echo $cartItem->getFinalPrice()."<br>";
echo $cartItem->getRegularPrice()."<br>";
echo $cartItem['regularprice']."<br>"; //This is my attribute values.I want to apply this value instead of final price.
}
}
}
?>
或者是否可以改变计算特价的方式。如果是,我需要覆盖哪个文件。
【问题讨论】:
标签: magento magento-1.7