Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento Cookies and database work on page load
    primarykey
    data
    text
    <p>I want to do some database operations and get/set a cookie before the front page loads. for which event would i make the observer? I haven't gotten to the cookie creation yet in my research, right now i want to do some database manipulation at the event. I have an observer right now going off at <code>controller_front_send_response_before</code> and this is the error trace i'm getting.</p> <pre><code>Mage registry key "_singleton/" already exists Trace: #0 /var/www/html/app/Mage.php(192): Mage::throwException('Mage registry k...') #1 /var/www/html/app/Mage.php(446): Mage::register('_singleton/', false) #2 /var/www/html/app/code/core/Mage/Core/Model/App.php(1252): Mage::getSingleton(false) #3 /var/www/html/app/Mage.php(416): Mage_Core_Model_App-&gt;dispatchEvent('controller_fron...', Array) #4 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(186): Mage::dispatchEvent('controller_fron...', Array) #5 /var/www/html/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front-&gt;dispatch() #6 /var/www/html/app/Mage.php(627): Mage_Core_Model_App-&gt;run(Array) #7 /var/www/html/index.php(86): Mage::run('', 'store') #8 {main} </code></pre> <p>This is my config node:</p> <pre><code>&lt;frontend&gt; ... &lt;events&gt; &lt;controller_front_send_response_before&gt; &lt;observers&gt; &lt;type&gt;singleton&lt;/type&gt; &lt;class&gt;Foo_Bar_Model_Observer&lt;/class&gt; &lt;method&gt;controllerFrontSendResponseBefore&lt;/method&gt; &lt;/observers&gt; &lt;/controller_front_send_response_before&gt; &lt;/events&gt; &lt;/frontend&gt; </code></pre> <p>And this is my observer model</p> <pre><code>class Foo_Bar_Model_Observer { public function controllerFrontSendResponseBefore(Varien_Event_Observer $observer) { $id = 1; $theVisitors = Mage::getModel('visitors/visitor'); $theVisitors-&gt;load($id); $numVisits = (int)$theVisitors-&gt;getNumvisits(); ++$numVisits; $theVisitors-&gt;setNumvisits($numVisits); $theVisitors-&gt;save(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload