0

I just want to display my event name :

app\etc\modules\Gta_RestrictProductByCountry.xml

<?xml version="1.0"?>

<config>

    <modules>

        <Gta_RestrictProductByCountry>

            <codePool>local</codePool>
            <active>true</active>

        </Gta_RestrictProductByCountry>

    </modules>

</config>

app\code\local\Gta\RestrictProductByCountry\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Gta_RestrictProductByCountry>
            <version>1.0.0</version>
        </Gta_RestrictProductByCountry>
    </modules>
    <global> 
        <models>
            <gta_restrictproductbycountry>
                <class>Gta_RestrictProductByCountry_Model</class>
            </gta_restrictproductbycountry>
        </models> 
     </global> 
    <frontend>
        <events>
            <!-- <sales_order_place_before> -->
            <checkout_cart_product_add_after>
                <observers>
                    <gta_restrictproductbycountry_observer>   
                        <type>singleton</type>
                        <class>gta_restrictproductbycountry/observer</class>
                        <method>cartevent</method>
                    </gta_restrictproductbycountry_observer>
                </observers>
            <!-- </sales_order_place_before>       -->
            </checkout_cart_product_add_after>      
        </events>
    </frontend>

</config>

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

<?php
class Gta_RestrictProductByCountry_Model_Observer
{
    public function cartevent($Observer)
    {

        $cart_product_check = $Observer->getEvent();
        Mage::log($cart_product_check->getName(), null, 'orderproduct.log',true);
    }
}
  • what is the issue - i mean event is not working ? – Anas Mansuri Oct 14 '19 at 6:36
  • Yes, after placed an order 'orderproduct.log' not generated in var/log – zus Oct 14 '19 at 6:37
0

Please try update below code :

<checkout_cart_product_add_after>
                <observers>
                    <gta_restrictproductbycountry_observer>   
                        <type>singleton</type>
                   <class>gta_restrictproductbycountry/observer</class>
                        <method>cartevent</method>
                    </gta_restrictproductbycountry_observer>
                </observers>
            </checkout_cart_product_add_after> 

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

<?php
class Gta_RestrictProductByCountry_Model_Observer
{
    public function cartevent($Observer)
    {

        $cart_product_check = $Observer->getEvent();
        Mage::log($cart_product_check->getName(), null, 'orderproduct.log',true);
    }
}
| improve this answer | |
  • Pls check with my updated post, still 'orderproduct.log' not generated under var/log @Anas Mansuri – zus Oct 14 '19 at 7:05
  • can you please replace with - <gta_restrictproductbycountry_observer> – Anas Mansuri Oct 14 '19 at 7:06
  • Still no luck, orderproduct.log not generated. – zus Oct 14 '19 at 7:17
  • pls check with my updated post – zus Oct 14 '19 at 7:19
  • please check i update my answer – Anas Mansuri Oct 14 '19 at 7:25
0

Finally done with below changes,

<frontend>
        <events>
            <!-- <sales_order_place_before> -->
            <checkout_cart_product_add_after>
                <observers>
                    <Gta_RestrictProductByCountry_Model_Observer>   
                        <type>singleton</type>
                        <class>Gta_RestrictProductByCountry_Model_Observer</class>
                        <method>cartevent</method>
                    </Gta_RestrictProductByCountry_Model_Observer>
                </observers>
            <!-- </sales_order_place_before>       -->
            </checkout_cart_product_add_after>      
        </events>
    </frontend>
| improve this answer | |

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.