Magento Observer事件未在服务器中触发,但在本地工作 [英] Magento Observer Event not firing in server but working in local

查看:41
本文介绍了Magento Observer事件未在服务器中触发,但在本地工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将代码移到服务器时遇到了问题.在我的本地系统中它运行正常.

I am facing the issue when i move the code to server.It is working fine in my local system.

当我搜索该问题时,发现我必须在配置文件中使用大写字母.

when i searched about the issue i found i have to use capital letters in config file.

我已将配置文件更新为大写,但问题仍然存在.

I have updated the config file to caps but still the issue exist.

请提出建议.

Config.xml

Config.xml

<?xml version="1.0"?>
<config>
    <modules>
            <Mdl_Ajaxcheckout>
                    <version>0.1.0</version>
                    <depends>
                            <Mage_Customer />
                            <Mage_Checkout />
                    </depends>
            </Mdl_Ajaxcheckout>
    </modules>
    <global>
        <models>
            <mdlajaxcheckout>
                <class>Mdl_Ajaxcheckout_Model</class>
            </mdlajaxcheckout>
        </models>

        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <mdl_ajaxcheckout_model_observer>
                        <class>Mdl_Ajaxcheckout_Model_Observer</class>
                        <method>modifyPrice</method>
                    </mdl_ajaxcheckout_model_observer>
                </observers>
            </checkout_cart_product_add_after>
        </events>

        <blocks>
            <mdlajaxcheckout>
                <class>Mdl_Ajaxcheckout_Block</class>
            </mdlajaxcheckout>
        </blocks>
        <helpers>
            <mdlajaxcheckout>
                <class>Mdl_Ajaxcheckout_Helper</class>
            </mdlajaxcheckout>
        </helpers>
    </global>
    <frontend>
        <layout>
            <updates>
                <mdlajaxcheckout>
                    <file>mdlajaxcheckout.xml</file>
                </mdlajaxcheckout>
            </updates>
        </layout>
        <translate>
            <modules>
                <Mdl_Ajaxcheckout>
                    <files>
                        <default>mdl_ajaxcheckout.csv</default>
                    </files>
                </Mdl_Ajaxcheckout>
            </modules>
        </translate>
    </frontend>
    <frontend>
        <routers>
            <mdlajaxcheckout>
                <use>standard</use>
                <args>
                    <module>Mdl_Ajaxcheckout</module>
                    <frontName>mdlajaxcheckout</frontName>
                </args>
            </mdlajaxcheckout>
        </routers>
    </frontend>
    <adminhtml>
        <acl>
            <resources>
                <admin>
                    <children>
                        <catalog>
                            <children>
                                <mdlajaxcheckout_adminform>
                                    <title>Configuration</title>
                                </mdlajaxcheckout_adminform>
                            </children>
                        </catalog>
                    </children>
                </admin>
            </resources>
        </acl>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <mdlajaxcheckout>
                                            <title>Mdl Ajax Cart</title>
                                        </mdlajaxcheckout>
                                    </children>
                                </config>
                            </children>
                        </system>
                        <customer>
                            <children>
                                <mdlajaxcheckout translate="title">
                                    <title>Mdl Ajax Cart</title>
                                    <sort_order>45</sort_order>
                                </mdlajaxcheckout>
                            </children>
                        </customer>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>
    <default>
        <mdlajaxcheckout>
            <default>
                <mdl_ajax_cart_loading_size>260x50</mdl_ajax_cart_loading_size>
                <mdl_ajax_cart_confirm_size>320x134</mdl_ajax_cart_confirm_size>
                <mdl_ajax_cart_image_size>55x55</mdl_ajax_cart_image_size>
                <mdl_ajax_cart_show_popup>1</mdl_ajax_cart_show_popup>
            </default>
        </mdlajaxcheckout>
    </default>
        <global>
    </global>
</config>

Observer.php

Observer.php

<?php
class Mdl_Ajaxcheckout_Model_Observer
{
    public function modifyPrice(Varien_Event_Observer $obs)
    {
        // Get the quote item
        $item = $obs->getQuoteItem();

        // Ensure we have the parent item, if it has one
        $item = ( $item->getParentItem() ? $item->getParentItem() : $item );
        //$demo=new Mdl_Ajaxcheckout_IndexController();
        // Load the custom price
        $price ="20";
        // Set the custom price
        $item->setCustomPrice($price);
        $item->setOriginalCustomPrice($price);
        // Enable super mode on the product.
        $item->getProduct()->setIsSuperMode(true);
        Mage::getSingleton('core/session')->setWelcomeMessage();
    }



}
?>

启用模块的代码.

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Mdl_Ajaxcheckout>

            <!-- Whether our module is active: true or false -->
            <active>true</active>

            <!-- Which code pool to use: core, community or local -->
            <codePool>community</codePool>

        </Mdl_Ajaxcheckout>
    </modules>
</config>

推荐答案

最后,我得到了上述线程的解决方案.

Finally I got the solution for above thread.

我们需要在admin中禁用编译器状态.

We need to disable the compiler status in admin.

系统->工具->编译->单击禁用.

system->tools->compilation->click disable.

现在您的观察者事件将起作用.

Now your observer event will work.

这篇关于Magento Observer事件未在服务器中触发,但在本地工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆