Exemplo n.º 1
0
 public function testLoadByCustomerId()
 {
     $customerId = 1;
     $customerIdFieldName = 'customer_id';
     $sharingCode = 'expected_sharing_code';
     $this->eventDispatcher->expects($this->any())->method('dispatch');
     $this->resource->expects($this->any())->method('getCustomerIdFieldName');
     $this->resource->expects($this->once())->method('load')->with($this->logicalOr($this->wishlist, $customerId, $customerIdFieldName));
     $this->mathRandom->expects($this->once())->method('getUniqueHash')->will($this->returnValue($sharingCode));
     $this->assertInstanceOf('Magento\\Wishlist\\Model\\Wishlist', $this->wishlist->loadByCustomerId($customerId, true));
     $this->assertEquals($customerId, $this->wishlist->getCustomerId());
     $this->assertEquals($sharingCode, $this->wishlist->getSharingCode());
 }
Exemplo n.º 2
0
 /**
  * Retrieve customer wishlist model object
  *
  * @param bool $cacheReload pass cached wishlist object and get new one
  * @return \Magento\Wishlist\Model\Wishlist|false Return false if customer ID is not specified
  */
 public function getCustomerWishlist($cacheReload = false)
 {
     if (!is_null($this->_wishlist) && !$cacheReload) {
         return $this->_wishlist;
     }
     $customerId = (int) $this->getSession()->getCustomerId();
     if ($customerId) {
         $this->_wishlist = $this->_objectManager->create('Magento\\Wishlist\\Model\\Wishlist');
         $this->_wishlist->loadByCustomerId($customerId, true);
         $this->_wishlist->setStore($this->getSession()->getStore())->setSharedStoreIds($this->getSession()->getStore()->getWebsite()->getStoreIds());
     } else {
         $this->_wishlist = false;
     }
     return $this->_wishlist;
 }
Exemplo n.º 3
0
 /**
  * Retrieve wishlist by logged in customer
  *
  * @return \Magento\Wishlist\Model\Wishlist
  */
 public function getWishlist()
 {
     if (is_null($this->_wishlist)) {
         if ($this->_coreRegistry->registry('shared_wishlist')) {
             $this->_wishlist = $this->_coreRegistry->registry('shared_wishlist');
         } else {
             $this->_wishlist = $this->wishlistProvider->getWishlist();
             if (!$this->_wishlist) {
                 $this->_wishlist = $this->_wishlistFactory->create();
                 if ($this->getCustomer()) {
                     $this->_wishlist->loadByCustomerId($this->getCustomer()->getId());
                 }
             }
         }
     }
     return $this->_wishlist;
 }