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_Sales_Order_Create_Sidebar_Pviewed extends Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Abstract
00036 {
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('sales_order_create_sidebar_pviewed');
00041 $this->setDataId('pviewed');
00042 }
00043
00044 public function getHeaderText()
00045 {
00046 return Mage::helper('sales')->__('Recently Viewed Products');
00047 }
00048
00049
00050
00051
00052
00053
00054 public function getItemCollection()
00055 {
00056 $productCollection = $this->getData('item_collection');
00057 if (is_null($productCollection)) {
00058 $stores = array();
00059 $website = Mage::app()->getStore($this->getStoreId())->getWebsite();
00060 foreach ($website->getStores() as $store) {
00061 $stores[] = $store->getId();
00062 }
00063
00064 $collection = Mage::getModel('reports/event')
00065 ->getCollection()
00066 ->addStoreFilter($stores)
00067 ->addRecentlyFiler(Mage_Reports_Model_Event::EVENT_PRODUCT_VIEW, $this->getCustomerId(), 0);
00068 $productIds = array();
00069 foreach ($collection as $event) {
00070 $productIds[] = $event->getObjectId();
00071 }
00072
00073 $productCollection = null;
00074 if ($productIds) {
00075 $productCollection = Mage::getModel('catalog/product')
00076 ->getCollection()
00077 ->setStoreId($this->getQuote()->getStoreId())
00078 ->addStoreFilter($this->getQuote()->getStoreId())
00079 ->addAttributeToSelect('name')
00080 ->addAttributeToSelect('price')
00081 ->addAttributeToSelect('small_image')
00082 ->addIdFilter($productIds)
00083 ->load();
00084 }
00085 $this->setData('item_collection', $productCollection);
00086 }
00087 return $productCollection;
00088 }
00089
00090
00091
00092
00093
00094
00095 public function canRemoveItems()
00096 {
00097 return false;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 public function getIdentifierId($item)
00107 {
00108 return $item->getId();
00109 }
00110 }