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.
@Aveeva Please replace mage with Mage in below code.
mage::log('You are Tester',null,'my_test.log',true);Thanks
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);
}
}
}
}
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?)
@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.
@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>
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.