dongnai8013 2012-01-04 08:56
浏览 51

在magento中击中计数器

How do I count the number of views(Hits) in magento? Are there any built in methods available in magento?

EDIT from the comment:

I need total views for the entire site. I got the online users count from this code:

$visitor_count = Mage::getModel('log/visitor_online')
                    ->prepare()
                    ->getCollection()
                    ->count(); 
if(!empty($visitor_count) && $visitor_count > 0) {
    $cnt = $visitor_count; 
    echo 'Visitors online :'.$cnt; 
} 
  • 写回答

3条回答 默认 最新

  • duanbo6871 2012-01-04 15:52
    关注

    The main table that you can use log_visitor So, here is the code:

    $totalUser = Mage::getSingleton('core/resource')->getConnection('core_write');
    $queryTotal=$totalUser->query("SELECT * FROM log_visitor ORDER BY visitor_id DESC LIMIT 1 ");
    // the result will give you maximum visitor_id
    
    评论

报告相同问题?