Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @api
- * @param int $productId
- * @return array
- */
- public function addProduct($productId){
- $userType = $this->userContext->getUserType();
- $product = null;
- $customerId = null;
- if($this->isLoggedIn()){
- $customerId = $this->userContext->getUserId();
- //$this->item->setCustomerId($customerId);
- }
- $product = $this->productRepository->getById($productId,false,1);
- $this->catalogProductCompareList->addProduct($product);
- $viewData = [
- 'product_id' => $productId,
- 'customer_id' => $customerId,
- 'visitor_id' => $this->visitor->getId()
- ];
- $this->compareFactory->create()->setData($viewData)->save();
- $collection = $this->catalogProductCompareList->getItemCollection();
- $a = array();
- //foreach($collection as $item){
- array_push($a, $collection->getData());
- //}
- return $a;
Add Comment
Please, Sign In to add comment