1
你能否看到爲什麼我的觀察者中的Mage :: log沒有射擊?非常沮喪。我期待他們在將商品添加到購物車後登錄,但他們不是。你能看到問題嗎? 我已啓用日誌記錄。模塊顯示在config> advanced下的列表中。我已禁用緩存,但我正在清除以確保衡量。Magento模塊觀察員沒有射擊
config.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Caitlinhavener_Dynamicprice>
<version>0.1.0</version>
</Caitlinhavener_Dynamicprice>
</modules>
<global>
<models>
<chdispatcher>
<class>Caitlinhavener_Dynamicprice_Model</class>
</chdispatcher>
</models>
<frontend>
<events>
<checkout_cart_product_add_after>
<observers>
<modify_to_custom_price>
<class>Caitlinhavener_Dynamicprice_Model_Observer</class>
<method>modifyPrice</method>
</modify_to_custom_price>
</observers>
</checkout_cart_product_add_after>
</events>
</frontend>
</global>
</config>
Observer.php:
<?php
Mage::log('Im here')
or exit("unable to log");
class Caitlinhavener_Dynamicprice_Model_Observer
{
public function modifyPrice(Varien_Event_Observer $obs)
{
// Get the quote item
$item = $obs->getQuoteItem();
Mage::log('Get Quote Item '. var_dump($_item->debug());
// Ensure we have the parent item, if it has one
$item = ($item->getParentItem() ? $item->getParentItem() : $item);
Mage::log('Get parent item ' . var_dump($_item->debug());
// Load the custom price
//$price = "your custom price logic";
$price = Mage::registry('dynamic_tier_price');
Mage::log('Price is ' . $price);
// Set the custom price
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
// Enable super mode on the product.
$item->getProduct()->setIsSuperMode(true);
Mage::log('Item after super mode ' . var_dump($_item->debug());
}
}
?>