/**
  * {@inheritdoc}
  */
 public function getList($cartId)
 {
     /** @var $quoteIdMask QuoteIdMask */
     $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
     $cartItemList = $this->repository->getList($quoteIdMask->getQuoteId());
     /** @var $item CartItemInterface */
     foreach ($cartItemList as $item) {
         $item->setQuoteId($quoteIdMask->getMaskedId());
     }
     return $cartItemList;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getImages($cartId)
 {
     $itemData = [];
     /** @see code/Magento/Catalog/Helper/Product.php */
     $items = $this->itemRepository->getList($cartId);
     /** @var \Magento\Quote\Model\Quote\Item $cartItem */
     foreach ($items as $cartItem) {
         $allData = $this->itemPool->getItemData($cartItem);
         $itemData[$cartItem->getItemId()] = $allData['product_image'];
     }
     return $itemData;
 }
예제 #3
0
 /**
  * @return void
  */
 public function testGetList()
 {
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with(33)->will($this->returnValue($quoteMock));
     $itemMock = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', [], [], '', false);
     $quoteMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock]));
     $this->assertEquals([$itemMock], $this->repository->getList(33));
 }
예제 #4
0
 /**
  * Retrieve quote item data
  *
  * @return array
  */
 private function getQuoteItemData()
 {
     $quoteItemData = [];
     $quoteId = $this->checkoutSession->getQuote()->getId();
     if ($quoteId) {
         $quoteItems = $this->quoteItemRepository->getList($quoteId);
         foreach ($quoteItems as $index => $quoteItem) {
             $quoteItemData[$index] = $quoteItem->toArray();
             $quoteItemData[$index]['options'] = $this->getFormattedOptionValue($quoteItem);
             $quoteItemData[$index]['thumbnail'] = $this->imageHelper->init($quoteItem->getProduct(), 'product_thumbnail_image')->getUrl();
         }
     }
     return $quoteItemData;
 }
예제 #5
0
 /**
  * Retrieve quote item data
  *
  * @return array
  */
 private function getQuoteItemData()
 {
     $quoteItemData = [];
     $quoteId = $this->checkoutSession->getQuote()->getId();
     if ($quoteId) {
         $quoteItems = $this->quoteItemRepository->getList($quoteId);
         foreach ($quoteItems as $index => $quoteItem) {
             $quoteItemData[$index] = $quoteItem->toArray();
             $quoteItemData[$index]['options'] = $this->getFormattedOptionValue($quoteItem);
             $thumbnailSize = $this->viewConfig->getViewConfig()->getVarValue('Magento_Catalog', 'product_thumbnail_image_size');
             $quoteItemData[$index]['thumbnail'] = (string) $this->imageHelper->init($quoteItem->getProduct(), 'thumbnail')->resize($thumbnailSize);
         }
     }
     return $quoteItemData;
 }
예제 #6
0
 /**
  * Get cart item
  *
  * @param int $cartId
  * @param int $itemId
  * @return CartItemInterface|null
  * @throws NoSuchEntityException
  */
 protected function getQuoteItem($cartId, $itemId)
 {
     $quoteItem = null;
     /** @var CartItemInterface[] $quoteItems */
     $quoteItems = $this->quoteItemRepository->getList($cartId);
     foreach ($quoteItems as $item) {
         if ($item->getItemId() == $itemId) {
             $quoteItem = $item;
             break;
         }
     }
     if (!$quoteItem) {
         throw new NoSuchEntityException(__('There is no item with provided id in the cart'));
     }
     return $quoteItem;
 }