1

Ok, I'm am very much a noob, but I am learning as I go and would love some advice on where I can check or what I can do to solve this issue.

Issue: I use m2e-Pro and a help desk extension on my site. I recently created a simply extension that uses the observer to monitor when a sale is completed and when it's completed it creates a help desk ticket and assigns the ticket to the order that was just created. The extension works great as far as I can tell... EXCEPT, i started noticing that M2ePro stopped automatically creating magento orders. M2epro still syncs with eBay and on the M2ePro sales tab for eBay you can see the ebay order, but you have to manually create the order. I removed my extension, and like magic m2ePro started automatically creating orders again.

Being that I'm a beginner I'm not sure where to check, but it's obvious that my extension is causing this. And it could also be causing other issues that I'm just not seeing.

My extension:

app/etc/modules/Trs_Orderhook.xml

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

app/code/local/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>

app/code/local/Trs/Orderhook/Model/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);

        }
    }
}

Like I said this code works great for what it's supposed to do. BUT it's affecting my m2e-Pro extension's ability to create orders automatically. I really appreciate the help!!!

  • Try wrapping your observer method in a try catch and log any exceptions in magentos log file and check php logs for any errors. – Ashley Swatton May 01 '16 at 04:52
  • Ok so I wasn't sure what the try catch was so i googled it... and it appears as though I would need something to test against to use that. Every example i saw essentially was saying: THIS is the value of exception. Now TRY something, if it meets criteria, throw exception, otherwise move on... So I'm not sure what it is I'm testing this against to trigger an exception. Is my confusion making any sense? – Brandon Cady May 01 '16 at 08:16

0 Answers0