I am trying to observe an event. How can I debug or know if the observer function has been called? I am using the event "checkout_cart_add_product_complete" and trying to do something simple when a product is added to the cart. But nothing happen when I add the product. I would like to know if the function was reached. My "events.xml":
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_cart_add_product_complete">
<observer name="send_order_tracy" instance="Tracy\ShippingMethod\Observer\SendOrderToTracy"/>
</event>
</config>
My observer class:
<?php
namespace Tracy\ShippingMethod\Observer;
class SendOrderToTracy implements \Magento\Framework\Event\ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
debug_to_console("por la chuchaaa");
//die('Observer Is called!');
}
function debug_to_console( $data ) {
$output = $data;
if ( is_array( $output ) )
$output = implode( ',', $output);
echo "<script>console.log( 'Debug Objects: " . $output . "' );</script>";
}
}