public function getCurrentStatus() { $log = $this->getCustomerLog(); if ($log->getLogoutAt() || strtotime(now()) - strtotime($log->getLastVisitAt()) > Mage_Log_Model_Visitor::getOnlineMinutesInterval() * 60) { return Mage::helper('customer')->__('Offline'); } return Mage::helper('customer')->__('Online'); }
/** * Enables online only select * * @param int $minutes * @return object */ public function useOnlineFilter($minutes = null) { if (is_null($minutes)) { $minutes = Mage_Log_Model_Visitor::getOnlineMinutesInterval(); } $this->_select->from(array('visitor_table' => $this->_visitorTable))->joinLeft(array('info_table' => $this->_visitorInfoTable), 'info_table.visitor_id=visitor_table.visitor_id')->joinLeft(array('customer_table' => $this->_customerTable), 'customer_table.visitor_id = visitor_table.visitor_id AND customer_table.logout_at IS NULL', array('log_id', 'customer_id', 'login_at', 'logout_at'))->joinLeft(array('url_info_table' => $this->_urlInfoTable), 'url_info_table.url_id = visitor_table.last_url_id')->where('visitor_table.last_visit_at >= ( ? - INTERVAL ' . $minutes . ' MINUTE)', now()); $customersCollection = AO::getModel('customer/customer')->getCollection(); /* @var $customersCollection Mage_Customer_Model_Entity_Customer_Collection */ $firstname = $customersCollection->getAttribute('firstname'); $lastname = $customersCollection->getAttribute('lastname'); $email = $customersCollection->getAttribute('email'); $this->_select->from('', array('type' => 'IF(customer_id, \'' . Mage_Log_Model_Visitor::VISITOR_TYPE_CUSTOMER . '\', \'' . Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR . '\')'))->joinLeft(array('customer_lastname_table' => $lastname->getBackend()->getTable()), 'customer_lastname_table.entity_id=customer_table.customer_id AND customer_lastname_table.attribute_id = ' . (int) $lastname->getAttributeId() . ' ', array('customer_lastname' => 'value'))->joinLeft(array('customer_firstname_table' => $firstname->getBackend()->getTable()), 'customer_firstname_table.entity_id=customer_table.customer_id AND customer_firstname_table.attribute_id = ' . (int) $firstname->getAttributeId() . ' ', array('customer_firstname' => 'value'))->joinLeft(array('customer_email_table' => $email->getBackend()->getTable()), 'customer_email_table.entity_id=customer_table.customer_id', array('customer_email' => 'email')); return $this; }