Ejemplo n.º 1
0
 /**
  * Saving information about customer
  *
  * @param   Mage_Log_Model_Visitor $visitor
  * @return  Mage_Log_Model_Mysql4_Visitor
  */
 protected function _saveCustomerInfo($visitor)
 {
     $write = $this->_getWriteAdapter();
     if ($visitor->getDoCustomerLogin()) {
         $write->insert($this->getTable('log/customer'), array('visitor_id' => $visitor->getVisitorId(), 'customer_id' => $visitor->getCustomerId(), 'login_at' => now(), 'store_id' => Mage::app()->getStore()->getId()));
         $visitor->setCustomerLogId($write->lastInsertId());
         $visitor->setDoCustomerLogin(false);
     }
     if ($visitor->getDoCustomerLogout() && ($logId = $visitor->getCustomerLogId())) {
         $write->update($this->getTable('log/customer'), array('logout_at' => now(), 'store_id' => Mage::app()->getStore()->getId()), $write->quoteInto('log_id=?', $logId));
         $visitor->setDoCustomerLogout(false);
         $visitor->setCustomerId(null);
         $visitor->setCustomerLogId(null);
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Saving information about customer
  *
  * @param   Mage_Log_Model_Visitor $visitor
  * @return  Mage_Log_Model_Resource_Visitor
  */
 protected function _saveCustomerInfo($visitor)
 {
     $adapter = $this->_getWriteAdapter();
     if ($visitor->getDoCustomerLogin()) {
         $data = new Varien_Object(array('visitor_id' => $visitor->getVisitorId(), 'customer_id' => $visitor->getCustomerId(), 'login_at' => Mage::getSingleton('core/date')->gmtDate(), 'store_id' => Mage::app()->getStore()->getId()));
         $bind = $this->_prepareDataForTable($data, $this->getTable('log/customer'));
         $adapter->insert($this->getTable('log/customer'), $bind);
         $visitor->setCustomerLogId($adapter->lastInsertId($this->getTable('log/customer')));
         $visitor->setDoCustomerLogin(false);
     }
     if ($visitor->getDoCustomerLogout() && ($logId = $visitor->getCustomerLogId())) {
         $data = new Varien_Object(array('logout_at' => Mage::getSingleton('core/date')->gmtDate(), 'store_id' => (int) Mage::app()->getStore()->getId()));
         $bind = $this->_prepareDataForTable($data, $this->getTable('log/customer'));
         $condition = array('log_id = ?' => (int) $logId);
         $adapter->update($this->getTable('log/customer'), $bind, $condition);
         $visitor->setDoCustomerLogout(false);
         $visitor->setCustomerId(null);
         $visitor->setCustomerLogId(null);
     }
     return $this;
 }