{"action":"created","issue":{"url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/12","labels_url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/12/comments","events_url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/12/events","html_url":"https://github.com/ICEPAYdev/Magento/issues/12","id":123684268,"number":12,"title":"Get quote data from the observer instead of session","user":{"login":"JeroenVanLeusden","id":14925052,"avatar_url":"https://avatars.githubusercontent.com/u/14925052?v=3","gravatar_id":"","url":"https://api.github.com/users/JeroenVanLeusden","html_url":"https://github.com/JeroenVanLeusden","followers_url":"https://api.github.com/users/JeroenVanLeusden/followers","following_url":"https://api.github.com/users/JeroenVanLeusden/following{/other_user}","gists_url":"https://api.github.com/users/JeroenVanLeusden/gists{/gist_id}","starred_url":"https://api.github.com/users/JeroenVanLeusden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeroenVanLeusden/subscriptions","organizations_url":"https://api.github.com/users/JeroenVanLeusden/orgs","repos_url":"https://api.github.com/users/JeroenVanLeusden/repos","events_url":"https://api.github.com/users/JeroenVanLeusden/events{/privacy}","received_events_url":"https://api.github.com/users/JeroenVanLeusden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-23T16:10:23Z","updated_at":"2015-12-23T22:52:45Z","closed_at":null,"body":"The method `sales_order_place_before` in Model/Observer.php uses the session to fetch quote data. \r\n\r\nHowever when calling this method from a cronjob no session is available. Therefore it's better to get quote data directly from the observer.\r\n\r\nPatch to solve this issue.\r\n```patch\r\nFrom d5ee9552a023e9f5cf3e2350b97e7e932f239ec1 Mon Sep 17 00:00:00 2001\r\nFrom: Jeroen van Leusden <jeroen@h-o.nl>\r\nDate: Wed, 23 Dec 2015 16:55:14 +0100\r\nSubject: [PATCH] [SHOP-241] sales_order_place_before should not use session\r\n\r\n---\r\n app/code/community/Icepay/IceAdvanced/Model/Observer.php | 16 ++++++++++------\r\n 1 file changed, 10 insertions(+), 6 deletions(-)\r\n\r\ndiff --git a/app/code/community/Icepay/IceAdvanced/Model/Observer.php b/app/code/community/Icepay/IceAdvanced/Model/Observer.php\r\nindex 466d394..4cd91e7 100755\r\n--- a/app/code/community/Icepay/IceAdvanced/Model/Observer.php\r\n+++ b/app/code/community/Icepay/IceAdvanced/Model/Observer.php\r\n@@ -67,16 +67,20 @@ class Icepay_IceAdvanced_Model_Observer extends Mage_Payment_Block_Form_Containe\r\n      */\r\n     public function sales_order_place_before(Varien_Event_Observer $observer)\r\n     {\r\n-        $quote = Mage::getSingleton('checkout/session')->getQuote();\r\n+        /** @var Mage_Sales_Model_Order $order */\r\n+        $order = $observer->getData('order');\r\n         \r\n-        $paymentMethodCode = $quote->getPayment()->getMethodInstance()->getCode();\r\n-        $paymentMethodTitle = $quote->getPayment()->getMethodInstance()->getTitle();\r\n+        $paymentMethodCode = $order->getPayment()->getMethodInstance()->getCode();\r\n+        $paymentMethodTitle = $order->getPayment()->getMethodInstance()->getTitle();\r\n \r\n-        if (false === strpos($paymentMethodCode, 'icepayadv_'))\r\n-            return;\r\n+        if (false === strpos($paymentMethodCode, 'icepayadv_')) {\r\n+            return $this;\r\n+        }\r\n \r\n-        if (strtoupper($paymentMethodTitle) == 'AFTERPAY')\r\n+        if (strtoupper($paymentMethodTitle) == 'AFTERPAY') {\r\n+            $quote = Mage::getSingleton('checkout/session')->getQuote();\r\n             $this->initAfterpayValidation($quote);\r\n+        }\r\n \r\n         return $this;\r\n     }\r\n-- \r\n2.5.4 (Apple Git-61)\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/comments/167004856","html_url":"https://github.com/ICEPAYdev/Magento/issues/12#issuecomment-167004856","issue_url":"https://api.github.com/repos/ICEPAYdev/Magento/issues/12","id":167004856,"user":{"login":"tsygankov","id":15112699,"avatar_url":"https://avatars.githubusercontent.com/u/15112699?v=3","gravatar_id":"","url":"https://api.github.com/users/tsygankov","html_url":"https://github.com/tsygankov","followers_url":"https://api.github.com/users/tsygankov/followers","following_url":"https://api.github.com/users/tsygankov/following{/other_user}","gists_url":"https://api.github.com/users/tsygankov/gists{/gist_id}","starred_url":"https://api.github.com/users/tsygankov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsygankov/subscriptions","organizations_url":"https://api.github.com/users/tsygankov/orgs","repos_url":"https://api.github.com/users/tsygankov/repos","events_url":"https://api.github.com/users/tsygankov/events{/privacy}","received_events_url":"https://api.github.com/users/tsygankov/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T22:52:45Z","updated_at":"2015-12-23T22:52:45Z","body":"Thank you for your contribution to the project!\r\n\r\nWe will test the solution you provided and include the change in one of the next releases."}}