Skip to content

Instantly share code, notes, and snippets.

@ProxiBlue
Created July 5, 2016 14:48
Show Gist options
  • Save ProxiBlue/9859e437ad0cf548fcbb6e9f41c0cb81 to your computer and use it in GitHub Desktop.
Save ProxiBlue/9859e437ad0cf548fcbb6e9f41c0cb81 to your computer and use it in GitHub Desktop.
inject vars to session
protected $_paramsToTrack = array("offer_followup");
/**
* Capture any listened for parameters, and inject them into the session
* under a variable called : ProductOfferUrlParams
*
* You must clear this variable with a call to
*
* Mage::getSingleton('customer/session')->unsProductOfferUrlParams();
*
* if the usage is no longer required, and it may trigger actions no longer
* required.
*
*
* @param Varien_Event_Observer $observer
*
* @return Viyet_ProductOffers_Model_Observer
*/
public function controller_front_send_response_before(Varien_Event_Observer $observer)
{
try {
if (Mage::getStoreConfig('productoffers/followup/disabled') == false) {
$request = $observer->getFront()->getAction()->getRequest();
$params = $request->getParams();
if (0 === count(array_diff($this->_paramsToTrack, array_keys($params)))) {
Mage::getSingleton('customer/session')->setProductOfferUrlParams($params);
}
}
} catch (Exception $e) {
// log any issues, but allow system to continue.
mage::logException($e);
}
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment