I am trying to create an observer on a specific event to save on session the url referrer.
I created this structure: http://screencast.com/t/TG7brmUi
The module seems OK, I can see on magento config. http://screencast.com/t/5d4FXIJwrGk
the code is as follows:
Luisvalencia_Affiliate.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Luisvalencia_Affiliate>
<active>true</active>
<codePool>community</codePool>
</Luisvalencia_Affiliate>
</modules>
</config>
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Luisvalencia_Affiliate>
<version>0.0.1</version>
</Luisvalencia_Affiliate>
</modules>
<frontend>
<events>
<controller_action_predispatch>
<observers>
<luisvalencia_affiliate>
<class>luisvalencia_affiliate/observer</class>
<method>captureReferral</method>
<type>singleton</type>
</luisvalencia_affiliate>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
and Observer.php
<?php
class Luisvalencia_Affiliate_Model_Observer
{
const COOKIE_KEY_SOURCE = 'luisvalencia_affiliate_source';
public function captureReferral(Varien_Event_Observer $observer)
{
$referrer=Mage::app()->getRequest()->getServer('HTTP_REFERER');
Mage::getSingleton('core/session')->setReferrer($referrer);
$outputMessage = Mage::getSingleton('core/session')->getReferrer();
echo $this->__($outputMessage);
}
protected function _getCookieLifetime()
{
$days = 1;
// convert to seconds
return (int)86400 * $days;
}
}
However I still see this on system.log, I dont understand.
2014-08-13T15:50:17+00:00 ERR (3): Warning: include(Mage/Luisvalencia/Affiliate/Model/Observer.php): failed to open stream: No such file or directory in /home/theprint/public_html/preprod/lib/Varien/Autoload.php on line 93
2014-08-13T15:50:17+00:00 ERR (3): Warning: include(Mage/Luisvalencia/Affiliate/Model/Observer.php): failed to open stream: No such file or directory in /home/theprint/public_html/preprod/lib/Varien/Autoload.php on line 93
2014-08-13T15:50:17+00:00 ERR (3): Warning: include(): Failed opening 'Mage/Luisvalencia/Affiliate/Model/Observer.php' for inclusion (include_path='/home/theprint/public_html/preprod/app/code/local:/home/theprint/public_html/preprod/app/code/community:/home/theprint/public_html/preprod/app/code/core:/home/theprint/public_html/preprod/lib:.:/usr/lib/php:/usr/local/lib/php') in /home/theprint/public_html/preprod/lib/Varien/Autoload.php on line 93