Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Viewed.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Framework\DataObject\IdentityInterface;
10 
17 class Viewed extends AbstractProduct implements IdentityInterface
18 {
22  const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count';
23 
30 
36  public function getPageSize()
37  {
38  if ($this->hasData('page_size')) {
39  return $this->getData('page_size');
40  }
41  return $this->_scopeConfig->getValue(
42  self::XML_PATH_RECENTLY_VIEWED_COUNT,
43  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
44  );
45  }
46 
52  public function getCount()
53  {
54  $ids = $this->getProductIds();
55  if (!empty($ids)) {
56  return count($ids);
57  }
58  return parent::getCount();
59  }
60 
67  protected function _toHtml()
68  {
69  $this->setRecentlyViewedProducts($this->getItemsCollection());
70  return parent::_toHtml();
71  }
72 
78  public function getIdentities()
79  {
80  $identities = [];
81  foreach ($this->getItemsCollection() as $item) {
82  $identities = array_merge($identities, $item->getIdentities());
83  }
84  return $identities;
85  }
86 }
getData($key='', $index=null)
Definition: DataObject.php:119