开发者

magento visitor logs

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, use开发者_如何学运维r 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());
}

I get an error 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


You need to use var_dump or var_export on php objects.

The following code will output each visitor object:

$visitors = Mage::getModel('log/visitor')->getCollection();

foreach ($visitors as $visitor) {
        var_dump($visitor);
}


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

For example

      $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'] . " - ";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜