65 \
Magento\Catalog\Model\
Product\Compare\ItemFactory $compareItemFactory,
69 \
Magento\Customer\Model\Visitor $customerVisitor,
72 $this->_compareItemFactory = $compareItemFactory;
73 $this->_itemCollectionFactory = $itemCollectionFactory;
74 $this->_catalogProductCompareItem = $catalogProductCompareItem;
75 $this->_customerSession = $customerSession;
76 $this->_customerVisitor = $customerVisitor;
77 parent::__construct(
$data);
89 $item = $this->_compareItemFactory->create();
93 if (!
$item->getId()) {
124 return $this->_itemCollectionFactory->create();
136 $item = $this->_compareItemFactory->create();
140 if (
$item->getId()) {
155 $item->addVisitorId($this->_customerVisitor->getId());
156 if ($this->_customerSession->isLoggedIn()) {
157 $item->setCustomerId($this->_customerSession->getCustomerId());
172 return (
bool)$this->_catalogProductCompareItem->getCount(
$customerId, $visitorId);
hasItems($customerId, $visitorId)
$_catalogProductCompareItem
__construct(\Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory, \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Visitor $customerVisitor, array $data=[])