magento访客日志 [英] magento visitor logs

查看:132
本文介绍了magento访客日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以访问Magento中的用户日志?我知道数据库有一个名为log_visitor的表,该表可以查看访问者的日志,而log_visitor_info记录有关访问者(IP,用户代理)的更多信息.我如何获得这些数据?当我写

Is there a way to access the user logs in Magento? I know the database has a table called log_visitor that can see logs visitors, and log_visitor_info logs more info about the visitors (IP, user agent). How do I get to that data? When I write

$visitors = Mage::getModel('log/visitor')->getCollection()
foreach ($visitors as $visitor)  {
    print_r($visitor->getData());
}

我收到错误PHP Fatal error: Uncaught exception 'Exception' with message 'Recoverable Error: Method Varien_Db_Select::__toString() must return a string value in /path/to/server/lib/Varien/Db/Adapter/Pdo/Mysql.php on line 272' in /path/to/server/app/code/core/Mage/Core/functions.php:239

推荐答案

如果不确定对象的API,则可以使用直接数据库查询.

You can use the direct database query if you're not sure about object's API.

例如

      $read = Mage::getSingleton('core/resource')->getConnection('core_read');

      $results = $read->fetchAll("select * from log_visitor_info");

      foreach($resulst as $res)
        echo $res['http_referer'] . " - " . $res['http_user_agent'] . " - " . $res['remote_addr'] . " - ";

这篇关于magento访客日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆