首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在magento中应用从我们自己的定制表中获取的价格

如何在magento中应用从我们自己的定制表中获取的价格
EN

Stack Overflow用户
提问于 2012-11-26 17:09:40
回答 1查看 782关注 0票数 2

我想要应用从我的定制表(比如my_own_prices)中获取的价格。在某些情况下,我不能使用magento的价格(如阶梯价格或特价),我需要从我的表中获取数据并将其应用于购物车。如果有可能,请回复。

EN

回答 1

Stack Overflow用户

发布于 2012-11-26 17:15:25

您可以使用catalog_product_get_final_price观察者来完成此操作。

首先在模块的etc/config.xml中声明观察者(假设你已经有了模块)

代码语言:javascript
复制
<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中添加以下方法:

代码语言:javascript
复制
public function catalogProductGetFinalPrice($observer)
{
    $product = $observer->getEvent()->getProduct();

    // Do your queries to your custom tables here and if necessary ..
    $product->setFinalPrice(..);
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13561661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档