2014-04-23 24 views
0

这是我如何形容sales_order_place_after事件无法在Observer中调用方法。 Magento的1.8

<models> 
     <chatattributes> 
      <class>Rockstar_Chatattributes_Model</class> 
     </chatattributes> 
     <chatattributes> 
      <class>Rockstar_Chatattributes_Model</class> 
      <resourceModel>chatattributes_resource</resourceModel> 
     </chatattributes> 
     <chatattributes_resource> 
      <class>Rockstar_Chatattributes_Model_Resource</class> 
     </chatattributes_resource> 
    </models> 
</global> 
    <frontend> 
     <events> 
      <sales_order_place_after> 
       <observers> 
        <place_order> 
         <type>singleton</type> 
         <class>chatattributes/observer</class> 
         <method>placeOrder</method> 
        </place_order> 
       </observers> 
      </sales_order_place_after> 
      <sales_quote_item_set_product> 
       <observers> 
        <quote_item> 
         <type>singleton</type> 
         <class>chatattributes/observer</class> 
         <method>setQuoteItem</method> 
        </quote_item> 
       </observers> 
      </sales_quote_item_set_product> 
      <add_to_cart_before> 
       <observers> 
        <add_to_cart> 
         <type>singleton</type> 
         <class>chatattributes/observer</class> 
         <method>addToCart</method> 
        </add_to_cart> 
       </observers> 
      </add_to_cart_before> 
     </events> 
    </frontend> 

这里是我的Observer.php(Rockstar的/ Chatattributes /型号/ Observer.php)

<?php 
class Rockstar_Chatattributes_Model_Observer 
{ 
    public function placeOrder($observer) { 
     var_dump('Never Ever change Magento Core code'); die; 
    } 

    public function setQuoteItem($observer) { 
     var_dump('quote item'); die; 
    } 

    public function addToCart($observer) { 
     var_dump('added to cart'); die; 
    } 
} 

所以,当我订货,我想在我的观察者中调用方法'placeOrder'...但我不能.....我已经删除了VAR文件夹并使用777权限再次创建它。

+0

你这里写任何更多的自定义观测方法的全球标签&下把? – DRAJI

+0

是的,我已更新的问题....请看看 –

+0

请不要调用两个自定义观察者方法。验证此帖子链接http://chillydraji.wordpress.com/2014/03/03/how-to-create-new-attribute-to-order-in-magento/ – DRAJI

回答

0

在您的XML中,您正在寻找带有'chatattributes'模型的Observer类。 模型的简写需要定义并与XML中的模型类相关。 对于你给模型,XML模式定义是这样的:

<global> 
    <models> 
     <chatattributes> 
     <class>CompanyName_ExtensionName_Model</class> 
     </chatattributes> 
    </models> 
    </global> 
+0

Hello Laizer,谢谢您的回答。我用模型节点更新了我的问题。请检查一下。 –

1

//不在前端标签

<global> 

     <events> 
      <sales_order_place_after> 
       <observers> 
        <place_order> 
         <type>singleton</type> 
         <class>chatattributes/observer</class> 
         <method>placeOrder</method> 
        </place_order> 
       </observers> 
      </sales_order_place_after> 
     </events> 

</global> 
+0

谢谢你的回答。我尝试过......没有帮助。 –

+0

你是否仍然在Observer.php上使用'CompanyName_ExtensionName'而不是'Rockstar_Chatattributes' ...我想..不是。但如果是这将是一个非常小的错误 –

+0

我试图展示的例子...我使用Rockstar_Chatattributes –