Example #1
0
 public function testGetProduct()
 {
     $productId = 1;
     $storeId = 0;
     $this->model->setData('product_id', $productId);
     $this->model->setData('store_id', $storeId);
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('setFinalPrice')->with(null);
     $productMock->expects($this->any())->method('setCustomOprtions')->with([]);
     $this->productRepository->expects($this->once())->method('getById')->willReturn($productMock);
     $this->assertEquals($productMock, $this->model->getProduct());
 }
Example #2
0
 /**
  * Load item by wishlist, product and shared stores
  *
  * @param \Magento\Wishlist\Model\Item $object
  * @param int $wishlistId
  * @param int $productId
  * @param array $sharedStores
  * @return $this
  */
 public function loadByProductWishlist($object, $wishlistId, $productId, $sharedStores)
 {
     $connection = $this->getConnection();
     $storeWhere = $connection->quoteInto('store_id IN (?)', $sharedStores);
     $select = $connection->select()->from($this->getMainTable())->where('wishlist_id=:wishlist_id AND ' . 'product_id=:product_id AND ' . $storeWhere);
     $bind = ['wishlist_id' => $wishlistId, 'product_id' => $productId];
     $data = $connection->fetchRow($select, $bind);
     if ($data) {
         $object->setData($data);
     }
     $this->_afterLoad($object);
     return $this;
 }