magento中产品的总观看次数

时间:2014-11-11 08:10:54

标签: php magento

如何获取magento中产品的总观看次数 我试过了     $ fromDate ='2010-01-01';     $ toDate = now();

$viewedProducts = Mage::getResourceModel('reports/product_collection')
            ->addViewsCount($fromDate, $toDate);

foreach($viewedProducts as $product) {
echo "ID: " . $product->getData('entity_id') . " - View Count: " . $product-       >getData('views') . "<br/>";}

1 个答案:

答案 0 :(得分:1)

<?php 

$id=$_helper->productAttribute($_product, $_product->getId(), 'id');
$fromDate = '2013-12-10';
$toDate   = now();
$viewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount($fromDate, $toDate);
foreach($viewedProducts as $product) {
if($product->getData('entity_id')==$id)
{
    echo  "Total View Count: " . $product->getData('views');
}}
?>