Compared.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Reports\Block\Product;
  7. /**
  8. * Reports Recently Compared Products Block
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. * @deprecated 100.2.0
  12. */
  13. class Compared extends \Magento\Reports\Block\Product\AbstractProduct
  14. {
  15. /**
  16. * Config path for compared products count
  17. */
  18. const XML_PATH_RECENTLY_COMPARED_COUNT = 'catalog/recently_products/compared_count';
  19. /**
  20. * Compared Product Index type
  21. *
  22. * @var string
  23. */
  24. protected $_indexType = \Magento\Reports\Model\Product\Index\Factory::TYPE_COMPARED;
  25. /**
  26. * Retrieve page size (count)
  27. *
  28. * @return int
  29. */
  30. public function getPageSize()
  31. {
  32. if ($this->hasData('page_size')) {
  33. return $this->getData('page_size');
  34. }
  35. return $this->_scopeConfig->getValue(
  36. self::XML_PATH_RECENTLY_COMPARED_COUNT,
  37. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  38. );
  39. }
  40. /**
  41. * Prepare to html
  42. * Check has compared products
  43. *
  44. * @return string
  45. */
  46. protected function _toHtml()
  47. {
  48. if (!$this->getCount()) {
  49. return '';
  50. }
  51. $this->setRecentlyComparedProducts($this->getItemsCollection());
  52. return parent::_toHtml();
  53. }
  54. }