Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /**
  2. * @api
  3. * @param int $productId
  4. * @return array
  5. */
  6. public function addProduct($productId){
  7. $userType = $this->userContext->getUserType();
  8. $product = null;
  9. $customerId = null;
  10.  
  11. if($this->isLoggedIn()){
  12. $customerId = $this->userContext->getUserId();
  13. //$this->item->setCustomerId($customerId);
  14. }
  15. $product = $this->productRepository->getById($productId,false,1);
  16. $this->catalogProductCompareList->addProduct($product);
  17. $viewData = [
  18. 'product_id' => $productId,
  19. 'customer_id' => $customerId,
  20. 'visitor_id' => $this->visitor->getId()
  21. ];
  22. $this->compareFactory->create()->setData($viewData)->save();
  23. $collection = $this->catalogProductCompareList->getItemCollection();
  24. $a = array();
  25. //foreach($collection as $item){
  26. array_push($a, $collection->getData());
  27. //}
  28. return $a;
Add Comment
Please, Sign In to add comment