00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Dashboard_Tab_Products_Viewed extends Mage_Adminhtml_Block_Dashboard_Grid
00036 {
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('productsReviewedGrid');
00042 }
00043
00044 protected function _prepareCollection()
00045 {
00046 if ($this->getParam('website')) {
00047 $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
00048 $storeId = array_pop($storeIds);
00049 } else if ($this->getParam('group')) {
00050 $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
00051 $storeId = array_pop($storeIds);
00052 } else {
00053 $storeId = (int)$this->getParam('store');
00054 }
00055 $collection = Mage::getResourceModel('reports/product_collection')
00056 ->addAttributeToSelect('*')
00057 ->addViewsCount()
00058 ->setStoreId($storeId)
00059 ->addStoreFilter($storeId);
00060
00061 $this->setCollection($collection);
00062
00063 return parent::_prepareCollection();
00064 }
00065
00066 protected function _prepareColumns()
00067 {
00068 $this->addColumn('name', array(
00069 'header' =>Mage::helper('reports')->__('Product Name'),
00070 'sortable' => false,
00071 'index' =>'name'
00072 ));
00073
00074 $this->addColumn('price', array(
00075 'header' =>Mage::helper('reports')->__('Price'),
00076 'width' =>'120px',
00077 'type' =>'currency',
00078 'currency_code' => (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode(),
00079 'sortable' => false,
00080 'index' =>'price'
00081 ));
00082
00083 $this->addColumn('views', array(
00084 'header' =>Mage::helper('reports')->__('Number of Views'),
00085 'width' =>'120px',
00086 'align' =>'right',
00087 'sortable' => false,
00088 'index' =>'views'
00089 ));
00090
00091 $this->setFilterVisibility(false);
00092 $this->setPagerVisibility(false);
00093
00094 return parent::_prepareColumns();
00095 }
00096
00097 public function getRowUrl($row)
00098 {
00099 $params = array('id'=>$row->getId());
00100 if ($this->getRequest()->getParam('store')) {
00101 $params['store'] = $this->getRequest()->getParam('store');
00102 }
00103 return $this->getUrl('*/catalog_product/edit', $params);
00104 }
00105 }