Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ImageProvider.php
Go to the documentation of this file.
1 <?php
7 
10 
16 {
20  protected $itemRepository;
21 
27  protected $itemPool;
28 
30  protected $customerDataItem;
31 
37  public function __construct(
38  \Magento\Quote\Api\CartItemRepositoryInterface $itemRepository,
39  \Magento\Checkout\CustomerData\ItemPoolInterface $itemPool,
40  \Magento\Checkout\CustomerData\DefaultItem $customerDataItem = null
41  ) {
42  $this->itemRepository = $itemRepository;
43  $this->itemPool = $itemPool;
44  $this->customerDataItem = $customerDataItem ?: ObjectManager::getInstance()->get(DefaultItem::class);
45  }
46 
50  public function getImages($cartId)
51  {
52  $itemData = [];
53 
55  $items = $this->itemRepository->getList($cartId);
57  foreach ($items as $cartItem) {
58  $allData = $this->customerDataItem->getItemData($cartItem);
59  $itemData[$cartItem->getItemId()] = $allData['product_image'];
60  }
61  return $itemData;
62  }
63 }
$cartId
Definition: quote.php:22
$items
__construct(\Magento\Quote\Api\CartItemRepositoryInterface $itemRepository, \Magento\Checkout\CustomerData\ItemPoolInterface $itemPool, \Magento\Checkout\CustomerData\DefaultItem $customerDataItem=null)