11 use Psr\Log\LoggerInterface;
58 private $_storeManager;
63 private $productRepository;
81 \
Magento\Sales\Model\Order\Config $orderConfig,
86 LoggerInterface $logger
88 $this->_orderCollectionFactory = $orderCollectionFactory;
89 $this->_orderConfig = $orderConfig;
90 $this->_customerSession = $customerSession;
104 $customerId = $this->_customerSession->getCustomerId();
106 $orders = $this->_orderCollectionFactory->create()
108 ->addAttributeToFilter(
'status', [
'in' => $this->_orderConfig->getVisibleOnFrontStatuses()])
109 ->addAttributeToSort(
'created_at',
'desc')
120 protected function getItems()
127 $website = $this->_storeManager->getStore()->getWebsiteId();
129 foreach (
$order->getParentItemsRandomCollection($limit) as
$item) {
132 $product = $this->productRepository->getById(
133 $item->getProductId(),
135 $this->_storeManager->getStore()->getId()
137 }
catch (NoSuchEntityException $noEntityException) {
138 $this->logger->critical($noEntityException);
144 'id' =>
$item->getId(),
145 'name' =>
$item->getName(),
165 $stockItem = $this->stockRegistry->getStockItem(
182 if (!$this->orders) {
185 foreach ($this->orders as
$order) {
195 return [
'items' => $this->getItems()];
__construct(\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Customer\Model\Session $customerSession, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\Store\Model\StoreManagerInterface $storeManager, ProductRepositoryInterface $productRepository, LoggerInterface $logger)
const SIDEBAR_ORDER_LIMIT
isItemAvailableForReorder(\Magento\Sales\Model\Order\Item $orderItem)