00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Adminhtml sales order create sidebar recently compared block 00029 * 00030 * @category Mage 00031 * @package Mage_Adminhtml 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 00035 class Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Pcompared 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_pcompared'); 00041 $this->setDataId('pcompared'); 00042 } 00043 00044 public function getHeaderText() 00045 { 00046 return Mage::helper('sales')->__('Recently Compared Products'); 00047 } 00048 00049 /** 00050 * Retrieve item collection 00051 * 00052 * @return mixed 00053 */ 00054 public function getItemCollection() 00055 { 00056 $productCollection = $this->getData('item_collection'); 00057 if (is_null($productCollection)) { 00058 // get products to skip 00059 $skipProducts = array(); 00060 if ($collection = $this->getCreateOrderModel()->getCustomerCompareList()) { 00061 $collection = $collection->getItemCollection() 00062 ->useProductItem(true) 00063 ->setStoreId($this->getStoreId()) 00064 ->setCustomerId($this->getCustomerId()) 00065 ->load(); 00066 foreach ($collection as $_item) { 00067 $skipProducts[] = $_item->getProductId(); 00068 } 00069 } 00070 00071 // prepare products collection and apply visitors log to it 00072 $productCollection = Mage::getModel('catalog/product')->getCollection() 00073 ->setStoreId($this->getQuote()->getStoreId()) 00074 ->addStoreFilter($this->getQuote()->getStoreId()) 00075 ->addAttributeToSelect('name') 00076 ->addAttributeToSelect('price') 00077 ->addAttributeToSelect('small_image'); 00078 Mage::getResourceSingleton('reports/event')->applyLogToCollection( 00079 $productCollection, Mage_Reports_Model_Event::EVENT_PRODUCT_COMPARE, $this->getCustomerId(), 0, $skipProducts 00080 ); 00081 00082 $productCollection->load(); 00083 $this->setData('item_collection', $productCollection); 00084 } 00085 return $productCollection; 00086 } 00087 00088 /** 00089 * Retrieve availability removing items in block 00090 * 00091 * @return bool 00092 */ 00093 public function canRemoveItems() 00094 { 00095 return false; 00096 } 00097 00098 /** 00099 * Get product Id 00100 * 00101 * @param Mage_Catalog_Model_Product $item 00102 * @return int 00103 */ 00104 public function getIdentifierId($item) 00105 { 00106 return $item->getId(); 00107 } 00108 00109 /** 00110 * Retrieve product identifier of block item 00111 * 00112 * @param mixed $item 00113 * @return int 00114 */ 00115 public function getProductId($item) { 00116 return $item->getId(); 00117 } 00118 }