/** * Init collection select * * @return $this */ protected function _initSelect() { parent::_initSelect(); $connection = $this->getConnection(); $lastDate = $this->date->gmtTimestamp() - $this->visitorModel->getOnlineInterval() * self::SECONDS_IN_MINUTE; $this->getSelect()->joinLeft(['customer' => $this->getTable('customer_entity')], 'customer.entity_id = main_table.customer_id', ['email', 'firstname', 'lastname'])->where('main_table.last_visit_at >= ?', $connection->formatDate($lastDate)); $expression = $connection->getCheckSql('main_table.customer_id IS NOT NULL AND main_table.customer_id != 0', $connection->quote(Visitor::VISITOR_TYPE_CUSTOMER), $connection->quote(Visitor::VISITOR_TYPE_VISITOR)); $this->getSelect()->columns(['visitor_type' => $expression]); return $this; }