PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/magento/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pcompared.php

https://bitbucket.org/jit_bec/shopifine
PHP | 118 lines | 54 code | 9 blank | 55 comment | 2 complexity | 575dd5832544c66a2b1a397413f09f5d MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Adminhtml
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Adminhtml sales order create sidebar recently compared block
  28. *
  29. * @category Mage
  30. * @package Mage_Adminhtml
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Pcompared extends Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Abstract
  34. {
  35. protected function _construct()
  36. {
  37. parent::_construct();
  38. $this->setId('sales_order_create_sidebar_pcompared');
  39. $this->setDataId('pcompared');
  40. }
  41. public function getHeaderText()
  42. {
  43. return Mage::helper('sales')->__('Recently Compared Products');
  44. }
  45. /**
  46. * Retrieve item collection
  47. *
  48. * @return mixed
  49. */
  50. public function getItemCollection()
  51. {
  52. $productCollection = $this->getData('item_collection');
  53. if (is_null($productCollection)) {
  54. // get products to skip
  55. $skipProducts = array();
  56. if ($collection = $this->getCreateOrderModel()->getCustomerCompareList()) {
  57. $collection = $collection->getItemCollection()
  58. ->useProductItem(true)
  59. ->setStoreId($this->getStoreId())
  60. ->setCustomerId($this->getCustomerId())
  61. ->load();
  62. foreach ($collection as $_item) {
  63. $skipProducts[] = $_item->getProductId();
  64. }
  65. }
  66. // prepare products collection and apply visitors log to it
  67. $productCollection = Mage::getModel('catalog/product')->getCollection()
  68. ->setStoreId($this->getQuote()->getStoreId())
  69. ->addStoreFilter($this->getQuote()->getStoreId())
  70. ->addAttributeToSelect('name')
  71. ->addAttributeToSelect('price')
  72. ->addAttributeToSelect('small_image');
  73. Mage::getResourceSingleton('reports/event')->applyLogToCollection(
  74. $productCollection, Mage_Reports_Model_Event::EVENT_PRODUCT_COMPARE, $this->getCustomerId(), 0, $skipProducts
  75. );
  76. $productCollection->load();
  77. $this->setData('item_collection', $productCollection);
  78. }
  79. return $productCollection;
  80. }
  81. /**
  82. * Retrieve availability removing items in block
  83. *
  84. * @return bool
  85. */
  86. public function canRemoveItems()
  87. {
  88. return false;
  89. }
  90. /**
  91. * Get product Id
  92. *
  93. * @param Mage_Catalog_Model_Product $item
  94. * @return int
  95. */
  96. public function getIdentifierId($item)
  97. {
  98. return $item->getId();
  99. }
  100. /**
  101. * Retrieve product identifier of block item
  102. *
  103. * @param mixed $item
  104. * @return int
  105. */
  106. public function getProductId($item) {
  107. return $item->getId();
  108. }
  109. }