Compared.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
  7. /**
  8. * Adminhtml sales order create sidebar compared block
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Compared extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar
  15. {
  16. /**
  17. * Constructor
  18. *
  19. * @return void
  20. */
  21. protected function _construct()
  22. {
  23. parent::_construct();
  24. $this->setId('sales_order_create_sidebar_compared');
  25. $this->setDataId('compared');
  26. }
  27. /**
  28. * Get header text
  29. *
  30. * @return \Magento\Framework\Phrase
  31. */
  32. public function getHeaderText()
  33. {
  34. return __('Products in Comparison List');
  35. }
  36. /**
  37. * Retrieve item collection
  38. *
  39. * @return mixed
  40. */
  41. public function getItemCollection()
  42. {
  43. $collection = $this->getData('item_collection');
  44. if ($collection === null) {
  45. if ($collection = $this->getCreateOrderModel()->getCustomerCompareList()) {
  46. $collection = $collection->getItemCollection()->useProductItem(
  47. true
  48. )->setStoreId(
  49. $this->getQuote()->getStoreId()
  50. )->addStoreFilter(
  51. $this->getQuote()->getStoreId()
  52. )->setCustomerId(
  53. $this->getCustomerId()
  54. )->addAttributeToSelect(
  55. 'name'
  56. )->addAttributeToSelect(
  57. 'price'
  58. )->addAttributeToSelect(
  59. 'image'
  60. )->addAttributeToSelect(
  61. 'status'
  62. )->load();
  63. }
  64. $this->setData('item_collection', $collection);
  65. }
  66. return $collection;
  67. }
  68. /**
  69. * Get item id
  70. *
  71. * @param \Magento\Framework\DataObject $item
  72. * @return int
  73. */
  74. public function getItemId($item)
  75. {
  76. return $item->getCatalogCompareItemId();
  77. }
  78. }