自定义扩展程序导致M2ePro

时间:2016-04-30 20:24:50

标签: php magento magento-1.9 m2e-pro

好吧,我非常喜欢菜鸟,但是我正在学习,并且会喜欢我可以检查的地方或者我可以做些什么来解决这个问题。

问题:我在我的网站上使用m2e-Pro和帮助台扩展程序。我最近创建了一个简单的扩展,它使用观察者来监控销售何时完成,当它完成时,它会创建一个帮助台票证,并将票证分配给刚刚创建的订单。据我所知,扩展程序很有效...除了我开始注意到M2ePro停止自动创建magento订单。 M2epro仍然与eBay同步,在eBay的M2ePro销售选项卡上,您可以看到ebay订单,但您必须手动创建订单。我删除了我的扩展程序,就像魔法m2ePro开始自动再次创建订单。

由于我是初学者,我不确定在哪里检查,但显然我的扩展程序导致了这一点。它也可能导致其他我没有看到的问题。

我的扩展名:

应用程序的/ etc /模块/ Trs_Orderhook.xml

<?xml version="1.0"?>
    <config>
        <modules>
            <Trs_Orderhook>
                <active>true</active>
                <codePool>local</codePool>
            </Trs_Orderhook>
        </modules>
</config>

应用程序/代码/本地/ TRS / Orderhook的/ etc / config.xml中

<?xml version="1.0"?>
<config>
    <modules>
        <Trs_Orderhook>
            <version>1.0</version>
        </Trs_Orderhook>

    </modules>

    <global>

        <models>
            <trs_orderhook>
                <class>Trs_Orderhook_Model</class>
            </trs_orderhook>
        </models>

       <events>
           <sales_order_place_after>
                <observers>
                    <trs_orderhook>
                        <class>trs_orderhook/observer</class>
                        <method>newTicket</method>
                    </trs_orderhook>
                </observers>
            </sales_order_place_after>
        </events>

    </global>

</config>

应用程序/代码/本地/ TRS / Orderhook /型号/ Observer.php

<?php

class Trs_Orderhook_Model_Observer 
{
    public function newTicket($observer)
    {

        $order = $observer->getOrder();//get Order data
        $orderId = $order->getId(); //get the Order ID
        $orderNumber = $order->getIncrementId(); //get Order Increment ID
        $order_customer = $order->getCustomerName(); //get Customer Name
        $customer_email = $order->getCustomer()->getEmail();//get customer email
        $customer_id = $order->getCustomer()->getId();//get customer id
        $order_date = $order->getCreatedAtStoreDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);//Get order date

        //This is data used to create ticket from Frontend of site
        $dataFrontend = array(
                "name"=>"Ticket for order # " . $orderNumber , 
                "message"=>"Welcome Message", 
                "order_id" => $orderId,
                "f_order_number" => $orderNumber,
                "f_order_date" => $order_date,
                );

        //This is the data used to create ticket from Admin Side
        $dataAdmin = array(
                "customer_email"=>$customer_email , 
                "allowCC"=> "false", 
                "allowBCC"=> "false", 
                "customer_query" =>"", 
                "customer_id" =>  $customer_id , 
                "order_id" => $orderId , 
                "name" => "Repair Ticket for order # " . $orderNumber ,
                "status_id" =>  "1", 
                "priority_id" =>  "3", 
                "owner" =>  "2_0", 
                "reply_type" =>  "public", 
                "third_party_email" =>  "" ,
                "reply" =>  "Welcome Message" ,
                "store_id" =>  "1" ,
                "f_order_number" => $orderNumber,
                "f_order_date" => $order_date,
                "tags" =>  "" ,
                "fp_period_unit" =>  "minutes", 
                "fp_period_value" =>  "" ,
                "fp_execute_at" => "",
                "fp_is_remind" =>  "0" ,
                "fp_remind_email" =>  "",
                "fp_status_id" =>  "0" ,
                "fp_priority_id" =>  "0" ,
                "fp_owner"=>  "0_0"
                );  

         //This is to check if the order is coming from frontend or backend
        if(!empty($order->getRemoteIp())){

            //This creates the ticket for frontend based orders
            Mage::helper('helpdesk/process')->createFromPost($dataFrontend, helpDeskExtension_Helpdesk_Model_Config::CHANNEL_CONTACT_FORM);  
        }

        else{

            //This creates the ticket for backend/admin based order
            $user = Mage::getSingleton('admin/session')->getUser(); 
            $ticket = Mage::helper('helpdesk/process')->createOrUpdateFromBackendPost($dataAdmin, $user);

        }
    }
}

就像我说的那样,这段代码非常适合它应该做的事情。但它影响了我的m2e-Pro扩展程序自动创建订单的能力。我非常感谢帮助!!!

0 个答案:

没有答案