12 class Clear extends \Magento\Catalog\Controller\Product\Compare implements HttpPostActionInterface
22 $items = $this->_itemCollectionFactory->create();
24 if ($this->_customerSession->isLoggedIn()) {
25 $items->setCustomerId($this->_customerSession->getCustomerId());
26 }
elseif ($this->_customerId) {
27 $items->setCustomerId($this->_customerId);
29 $items->setVisitorId($this->_customerVisitor->getId());
34 $this->messageManager->addSuccessMessage(
__(
'You cleared the comparison list.'));
35 $this->_objectManager->get(\
Magento\Catalog\Helper\
Product\Compare::class)->calculate();
37 $this->messageManager->addErrorMessage($e->getMessage());
38 }
catch (\Exception $e) {
39 $this->messageManager->addExceptionMessage($e,
__(
'Something went wrong clearing the comparison list.'));
43 $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
44 return $resultRedirect->setRefererOrBaseUrl();
elseif(isset( $params[ 'redirect_parent']))