You might have seen in Magento we have a section for seeing the online visitors at a given time.
<?php//this code can be written directly in the template file $visitor_count = Mage::getModel('log/visitor_online') ->prepare() ->getCollection()->count(); if(!empty($visitor_count) && $visitor_count > 0) { $cnt = $visitor_count; echo 'Visitors online :'.$cnt; }?>
Here is another way for doing this<?php//this code can be written directly in the template file $visitor_collection = Mage::getResourceModel('log/visitor_collection')->useOnlineFilter(); $visitor_count = count($visitor_collection); if(!empty($visitor_count) && $visitor_count > 0) { $cnt = $visitor_count; echo 'Visitors online :'.$cnt; } ?>
No comments:
Post a Comment