我想要应用从我的定制表(比如my_own_prices)中获取的价格。在某些情况下,我不能使用magento的价格(如阶梯价格或特价),我需要从我的表中获取数据并将其应用于购物车。如果有可能,请回复。
发布于 2012-11-26 17:15:25
您可以使用catalog_product_get_final_price观察者来完成此操作。
首先在模块的etc/config.xml中声明观察者(假设你已经有了模块)
<config>
...
<frontend>
<events>
<catalog_product_get_final_price>
<observers>
<something_unique_here>
<type>singleton</type>
<class>YourCompany_YourModule_Model_Observer</class>
<method>catalogProductGetFinalPrice</method>
</something_unique_here>
</observers>
</catalog_product_get_final_price>
</events>
</frontend>
...
</config>然后在模块的Model\Observer.php中添加以下方法:
public function catalogProductGetFinalPrice($observer)
{
$product = $observer->getEvent()->getProduct();
// Do your queries to your custom tables here and if necessary ..
$product->setFinalPrice(..);
}https://stackoverflow.com/questions/13561661
复制相似问题