Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WishlistProvider.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  protected $request;
17 
21  protected $wishlistFactory;
22 
26  protected $checkoutSession;
27 
31  protected $wishlist;
32 
38  public function __construct(
40  \Magento\Wishlist\Model\WishlistFactory $wishlistFactory,
41  \Magento\Checkout\Model\Session $checkoutSession
42  ) {
43  $this->request = $request;
44  $this->wishlistFactory = $wishlistFactory;
45  $this->checkoutSession = $checkoutSession;
46  }
47 
53  public function getWishlist($wishlistId = null)
54  {
55  if ($this->wishlist) {
56  return $this->wishlist;
57  }
58  $code = (string)$this->request->getParam('code');
59  if (empty($code)) {
60  return false;
61  }
62 
63  $wishlist = $this->wishlistFactory->create()->loadByCode($code);
64  if (!$wishlist->getId()) {
65  return false;
66  }
67 
68  $this->checkoutSession->setSharedWishlist($code);
69  $this->wishlist = $wishlist;
70  return $wishlist;
71  }
72 }
__construct(\Magento\Framework\App\RequestInterface $request, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, \Magento\Checkout\Model\Session $checkoutSession)
$code
Definition: info.phtml:12