2

I am using Sales_order_place_before event in my module. And the observer returns the error,

User Error: Some transactions have not been committed or rolled back  in C:\xampp\htdocs\cart\lib\Varien\Db\Adapter\Pdo\Mysql.php on line 3937"

config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Observersample_Event>
            <version>0.0.1</version>
        </Observersample_Event>
    </modules>
    <global>
        <models>
            <Observersample_Event>
                <class>Observersample_Event_Model</class>
            </Observersample_Event>
        </models>
        <events>
            <sales_order_place_before>
                <observers>
                    <observersample_event_model_observer>
                        <type>singleton</type>
                        <class>Observersample_Event_Model_Observer</class>
                        <method>example</method>
                    </observersample_event_model_observer>
                </observers>
            </sales_order_place_before>
        </events>
    </global>
</config>

Observer.php:

class Observersample_Event_Model_Observer{

    public function example($observer){
        Mage::log("Order is Placed");
        $order = $observer->getEvent()->getOrder();
        $billing = $order->getBillingAddress();
        $shipping = $order->getShippingAddress();
        $customer = $order->getCustomer();
        Mage::log($billing->getData());
        Mage::log($order->getData());
    }
}

systems.log:

2015-06-12T06:36:26+00:00 DEBUG (7): Order is Placed
2015-06-12T06:36:26+00:00 DEBUG (7): Array
(
)
2015-06-12T06:34:45+00:00 ERR (3): User Error: Some transactions have not been committed or rolled back  in C:\xampp\htdocs\cart\lib\Varien\Db\Adapter\Pdo\Mysql.php on line 3937

I hope someone will help me on this issue.

7
  • 1
    I can't explain exactly why, but I did have the same problem, just comment out the Mage::log part and I think you should be fine
    – lloiacono
    Jun 12, 2015 at 8:01
  • ok i will check @lloiacono...
    – Gayathri
    Jun 12, 2015 at 8:03
  • 1
    that error message is shown when you run some queries in the transaction and you don't commit the transaction. So something is stopping the order save process.
    – Marius
    Jun 12, 2015 at 8:05
  • But i have checked the order table,the order is placed...@Marius
    – Gayathri
    Jun 12, 2015 at 8:07
  • 1
    reomove log print and check
    – Amit Bera
    Jun 12, 2015 at 9:08

1 Answer 1

1

The problem is in the Mage::log($billing->getData()); This is not the correct format.. So changing this like,

Mage::log(var_export($billing->debug(), TRUE));

gives output.

Observer.php:

class Observersample_Event_Model_Observer{

    public function example($observer){
        $order = $observer->getEvent()->getOrder();
        $billing = $order->getBillingAddress();
        $shipping = $order->getShippingAddress();
        $customer = $order->getCustomer();
        Mage::log(var_export($order->debug(), TRUE), null,'order.log');
        Mage::log(var_export($billing->debug(),TRUE),null,'billing.log');
    }
}

for details check this: http://www.magentocommerce.com/wiki/5_-_modules_and_development/reference/debug

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.