Sep 17, 2013
64 Views

[Magento] Hiện số người Online – Hiển thị Customer, Guest, Total online

Written by

Vào
app\design\frontend\default\your theme\template\page\html\footer.phtml

chèn vào đoạn

$visitor_count = Mage::getModel('log/visitor_online')->prepare()->getCollection()->count();
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$readresult=$write->query("select count(distinct customer_id) as num_visitors from log_visitor_online where last_visit_at > date_sub(now(),INTERVAL 20 MINUTE); ");
$row = $readresult->fetch();$n=0;if($row['num_visitors']>0) $n = $row['num_visitors'];
echo "Customers online: ".$n;
$guest = $visitor_count-$n;
echo " | Guest online: ".$guest." | ";
if(!empty($visitor_count) && $visitor_count > 0){ $cnt = $visitor_count; echo 'Total online: '.$cnt;}

 

Article Tags:
Article Categories:
Code/Web
    http://linholiver.com

    https://linholiver.com/diary/about/