/**
  * 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->getDoCustomerLogout() && ($logId = $visitor->getCustomerLogId())) {
         $resource = Mage::getSingleton('core/resource');
         $connection = $resource->getConnection('core_read');
         $select = new Zend_Db_Select($connection);
         $select->from($resource->getTableName('log/customer'));
         $select->reset(Zend_Db_Select::COLUMNS);
         $select->columns('login_at');
         $select->where('log_id = ?', $logId);
         $loginAt = $connection->fetchOne($select);
         if (!$loginAt) {
             return parent::_saveCustomerInfo($visitor);
         }
         $data = new Varien_Object(array('login_at' => $loginAt, '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);
     } else {
         return parent::_saveCustomerInfo($visitor);
     }
     return $this;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }