[ic] free report of most frequently viewed products

Jeff Dafoe interchange-users@icdevgroup.org
Thu Jan 9 21:58:00 2003


Hello,

    At the bottom of
interchange/lib/UI/pages/admin/reports/traffic/ByAffiliate.html is a block
of commented out code.  If you put the following code either directly above
that or directly below it, you will get a fairly ghetto looking list of the
top ten most viewed items for the time period for which the report is being
run.


=====
  my @topsellers;
  my $product;
  my $maxsellers=10;
  for(my $i=0; $i<$maxsellers; $i++) {
    $topsellers[$i]=0;
  }
  for(keys %{$action_by_tag{VIEWPROD}}) {
    $product = $_;
    for(my $i=0; $i<$maxsellers; $i++) {
      if
($action_by_tag{VIEWPROD}{$product}>$action_by_tag{VIEWPROD}{$topsellers[$i]
}) {
        for(my $j=($maxsellers-1); $j==$i; $j--) {
          $topsellers[$j+1]=$topsellers[$j];
        }
        $topsellers[$i]=$product;
        last;
      }
    }
  }
  $out .= '<tr><td colspan=8>';
  for(my $i=0; $i<$maxsellers; $i++) {
    $out .=
$topsellers[$i].':'.$action_by_tag{VIEWPROD}{$topsellers[$i]}.'<br>';
  }
  $out .= '</td></tr>';

=====