- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020
10:27 PM
01-21-2020
10:27 PM
Magento 1.9 - What is the error in my Observer?
I just want to display if order placed from selected customer group display "You are Tester",
My observer :
\app\etc\modules\Gta_FindPaymentGateway.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Gta_FindPaymentGateway> <active>true</active> <codePool>local</codePool> </Gta_FindPaymentGateway> </modules> </config>
app\code\local\Gta\FindPaymentGateway\etc\config.xml
<?xml version="1.0"?> <config> <modules> <Gta_FindPaymentGateway> <version>1.0.0</version> </Gta_FindPaymentGateway> </modules> <global> <models> <gta_findpaymentgateway> <class>Gta_FindPaymentGateway_Model</class> </gta_findpaymentgateway> </models> </global> <frontend> <events> <sales_order_place_before> <observers> <Gta_FindPaymentGateway_Model_Observer> <type>singleton</type> <class>Gta_FindPaymentGateway_Model_Observer</class> <method>paymenter</method> </Gta_FindPaymentGateway_Model_Observer> </observers> </sales_order_place_before> </events> </frontend> </global> </config>
app\code\local\Gta\FindPaymentGateway\Model\Observer.php
<?php class Gta_FindPaymentGateway_Model_Observer { public function paymenter($Observer) { $order = $Observer->getEvent()->getOrder(); $login = $order-> Mage::getSingleton( 'customer/session' )->isLoggedIn(); if($login) { $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); if($groupId == 2) { mage::log('You are Tester',null,'my_test.log',true); } } } }
Log file not created.
Labels:
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020
10:49 PM
01-21-2020
10:49 PM
Re: Magento 1.9 - What is the error in my Observer?
@Aveeva Please replace mage with Mage in below code.
mage::log('You are Tester',null,'my_test.log',true);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020
11:14 PM
01-21-2020
11:14 PM
Re: Magento 1.9 - What is the error in my Observer?
Still not working.
observer :
<?php class Gta_FindPaymentGateway_Model_Observer { public function paymenter($Observer) { $order = $Observer->getEvent()->getOrder(); $login = $order-> Mage::getSingleton( 'customer/session' )->isLoggedIn(); if($login) { $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); if($groupId == 2) { Mage::log('You are Tester',null,'my_test.log',true); } } } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020
12:56 AM
01-22-2020
12:56 AM
Re: Magento 1.9 - What is the error in my Observer?
Hi @Aveeva
Move
Mage::log('You are Tester',null,'my_test.log',true);
before
if($groupId == 2) {
like
Mage::log($groupId, null, 'my_test.log', true);
if($groupId == 2) {
and see if it works. (Is it logging the groupid?)
---
Problem Solved Click Accept as Solution!:Magento Community India Forum
Problem Solved Click Accept as Solution!:Magento Community India Forum
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020
01:12 AM
01-22-2020
01:12 AM
Re: Magento 1.9 - What is the error in my Observer?
@Mukesh Tiwari Observer.php
<?php class Gta_FindPaymentGateway_Model_Observer { public function paymenter($Observer) { $order = $Observer->getEvent()->getOrder(); $login = $order-> Mage::getSingleton( 'customer/session' )->isLoggedIn(); if($login) { $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); Mage::log('Line no - 11'. $groupId,null,'my_test1.log',true); if($groupId == 2) { Mage::log('You are Tester',null,'my_test.log',true); } } } } ?>
still not creating log file.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020
01:18 AM
01-22-2020
01:18 AM
Re: Magento 1.9 - What is the error in my Observer?
@Mukesh Tiwari @Rahul Gupta I just want try to print what event i am using,
<?php class Gta_FindPaymentGateway_Model_Observer { public function paymenter($Observer) { $order = $Observer->getEvent(); Mage::log($order->getName(),null,'event.log',true); } } ?>
Above script not print log.
My config.xml file,
<?xml version="1.0"?> <config> <modules> <Gta_FindPaymentGateway> <version>1.0.0</version> </Gta_FindPaymentGateway> </modules> <global> <models> <gta_findpaymentgateway> <class>Gta_FindPaymentGateway_Model</class> </gta_findpaymentgateway> </models> <events> <sales_order_place_before> <observers> <Gta_FindPaymentGateway_Model_Observer> <type>singleton</type> <class>Gta_FindPaymentGateway_Model_Observer</class> <method>paymenter</method> </Gta_FindPaymentGateway_Model_Observer> </observers> </sales_order_place_before> </events> </global> </config>
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020
04:02 AM
01-22-2020
04:02 AM
Re: Magento 1.9 - What is the error in my Observer?
Change from following
<Gta_FindPaymentGateway_Model_Observer> <type>singleton</type> <class>Gta_FindPaymentGateway_Model_Observer</class> <method>paymenter</method> </Gta_FindPaymentGateway_Model_Observer>
to
<gta_findpaymentgateway_model_observer> <type>singleton</type> <class>Gta_FindPaymentGateway_Model_Observer</class> <method>paymenter</method> </gta_findpaymentgateway_model_observer>
and then check the results.
---
Problem Solved Click Accept as Solution!:Magento Community India Forum
Problem Solved Click Accept as Solution!:Magento Community India Forum
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020
09:08 PM
01-22-2020
09:08 PM