1

My Custom 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>   
        <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>

app\code\local\Gta\FindPaymentGateway\Model\Observer.php

<?php
    class Gta_FindPaymentGateway_Model_Observer
    {
        public function paymenter($Observer)
        {
             $order = $Observer->getEvent();
             Mage::log($order->getName(),null,'event.log',true);
        }
    }
?>

log not created.

Share any debug tool for magento?

  • Your code is correct and working for me. – Pawan Jan 22 at 10:39
  • check your log is enabled – Pawan Jan 22 at 10:40
  • Yes, my log enabled, other observer log files generated at var/log location, this one only not generate log file. – zus Jan 22 at 11:08
  • instead, logging order object try to log some plain text – Charlie Jan 22 at 11:36
  • justpaste.it/69ng1 still not generate log file. – zus Jan 22 at 11:46
1

People report your code to work correctly on their installations, so the issue obviously is specific to your setup or magento project's code base.

https://justpaste.it/7l2ka proves that your observer class isn't being parsed as php would fail with a syntax error doing so. For magento backend development I rely on magerun. It provides all kind of useful commands you should make yourself familiar with.

For a start I'd make sure that your module and observers show up with n98-magerun.phar config:dump modules and n98-magerun.phar dev:module:observer:list.

1

The observer code you shared in https://justpaste.it/7l2ka contains a die() which will break execution due to Fatal error (unexpected 'die' (T_EXIT))

    <?php
class Gta_FindPaymentGateway_Model_Observer
{
public function paymenter($Observer)
{
$order = $Observer->getEvent();
Mage::log($order->getName(), null,'event.log',true);
}
die(); // !!!!!!!!!!!!!! IS THIS STILL IN YOUR CODE ??? If yes remove it
}
?>
1

I have created module same as yours, Please check the below code.

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>
      <findpaymentgateway>
        <class>Gta_FindPaymentGateway_Model</class>
        <resourceModel>findpaymentgateway_mysql4</resourceModel>
      </findpaymentgateway>
    </models>
    <events>
      <sales_order_place_before> <!-- identifier of the event we want to catch -->
        <observers>
          <sales_order_place_before_handler> <!-- identifier of the event handler -->
            <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
            <class>findpaymentgateway/observer</class> <!-- observers class alias -->
            <method>paymenter</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </sales_order_place_before_handler>
        </observers>
      </sales_order_place_before>
    </events>
  </global>
</config> 

app\code\local\Gta\FindPaymentGateway\Model\Observer.php

<?php
class Gta_FindPaymentGateway_Model_Observer
{

    public function paymenter(Varien_Event_Observer $observer)
    {
        $event = $observer->getEvent();
        Mage::log($event->getName(),null,'event.log');
    }

}

Logfile created in var/log/event.log and print the sales_order_place_before, check the below screenshot.

enter image description here

Hope this will work for you.

  • I need how to get what event i am using. Code :magento.stackexchange.com/q/301862/57334 – zus Feb 3 at 4:40
  • I have updated my answer, Please check. – Kishor Thummar Feb 3 at 10:41
  • Same code what i post, still not generated log file. – zus Feb 3 at 10:44
  • Have you used the same code as I have posted in this answer for config.xml? – Kishor Thummar Feb 3 at 10:45
  • yes, using same code – zus Feb 3 at 11:18
0

Finally done restart my wamp server and also clear & flush cache.

-2

Kindly run php bin/magento setup:upgrade command and then php bin/magento s:s:d command then it should work fine. or you may refer to this question https://stackoverflow.com/questions/52081048/magento-1-9-magelog-isnt-creating-the-log-files

  • My magento ver : 1.9.2.3 – zus Jan 24 at 7:20
  • Not a Magento 2 problem – Ahsan Horani Jan 28 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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