I have the following magento code in a custom module sitting in my local folder.
public function ProofOfConecept(Varien_Event_Observer $observer)
{
//checkout_cart_save_before
Mage::log('ProofOfConecept called - 2', null, 'proofLog.log');
$cart = $observer->getEvent()->getCart();
if($cart != NULL)
{
Mage::log('$cart contains data!', null, 'proofLog.log');
$items = $cart->getItems();
if($items != NULL)
{
Mage::log('$items has the following -- '.$items, null, 'proofLog.log');
}else{
Mage::log('$items is null??', null, 'proofLog.log');
}
}else
{
Mage::log('sorry Cart is null :(', null, 'proofLog.log');
}
}
The code above is my method to call when an event is fired, Below is the config.xml code
<events>
<checkout_cart_save_before>
<observers>
<dotnetit_eccbundle_model_observer>
<type>singleton</type>
<class>DotNetIT_ECCbundle_Model_Observer</class>
<method>ProofOfConecept</method>
</dotnetit_eccbundle_model_observer>
</observers>
</checkout_cart_save_before>
</events>
when i update something in my cart the following is logged in my ProofLog.log file
2015-09-25T09:05:40+00:00 DEBUG (7): ProofOfConecept called - 2
2015-09-25T09:05:40+00:00 DEBUG (7): $cart contains data!
2015-09-25T09:05:40+00:00 DEBUG (7): $items has the following --
As you can see, the if statement is true that there does appear to be data in $items, however i cant seem to log the items, is this the correct syntax?
I cannot debug the project either, this code lives on production hence why I'm using Mage::log() for my debugging :(
Also I'm a .net web dev, and php magento is all new to me, last couple weeks I've been trying to learn as much as i can, so forgive me if the issue is a simple syntax mistake.
Thanks guys.