![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-reports/Model/Product/Index/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Reports\Model\Product\Index; /** * Catalog Compared Product Index Model * * @method \Magento\Reports\Model\Product\Index\Compared setVisitorId(int $value) * @method \Magento\Reports\Model\Product\Index\Compared setCustomerId(int $value) * @method int getProductId() * @method \Magento\Reports\Model\Product\Index\Compared setProductId(int $value) * @method \Magento\Reports\Model\Product\Index\Compared setStoreId(int $value) * @method string getAddedAt() * @method \Magento\Reports\Model\Product\Index\Compared setAddedAt(string $value) * * @author Magento Core Team <[email protected]> * @api * @since 100.0.2 */ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex { /** * Cache key name for Count of product index * * @var string */ protected $_countCacheKey = 'product_index_compared_count'; /** * Catalog product compare * * @var \Magento\Catalog\Helper\Product\Compare */ protected $_productCompare = null; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Helper\Product\Compare $productCompare * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Catalog\Helper\Product\Compare $productCompare, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { parent::__construct( $context, $registry, $storeManager, $customerVisitor, $customerSession, $reportSession, $productVisibility, $dateTime, $resource, $resourceCollection, $data ); $this->_productCompare = $productCompare; } /** * Initialize resource model * * @return void */ protected function _construct() { $this->_init(\Magento\Reports\Model\ResourceModel\Product\Index\Compared::class); } /** * Retrieve Exclude Product Ids List for Collection * * @return array */ public function getExcludeProductIds() { $productIds = []; if ($this->_productCompare->hasItems()) { foreach ($this->_productCompare->getItemCollection() as $_item) { $productIds[] = $_item->getEntityId(); } } if ($this->_registry->registry('current_product')) { $productIds[] = $this->_registry->registry('current_product')->getId(); } return array_unique($productIds); } }