28 private $itemsCollection;
34 private $itemCollectionFactory;
39 private $joinAttributeProcessor;
46 private $isPagerDisplayed;
68 \
Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor,
71 $this->itemCollectionFactory = $itemCollectionFactory;
72 $this->joinAttributeProcessor = $joinProcessor;
95 if (!$this->isPagerDisplayedOnPage()) {
98 if ($this->
hasData(
'template')) {
109 parent::_prepareLayout();
110 if ($this->isPagerDisplayedOnPage()) {
111 $availableLimit = (int)$this->_scopeConfig->getValue(
112 self::XPATH_CONFIG_NUMBER_ITEMS_TO_DISPLAY_PAGER,
115 $itemsCollection = $this->getItemsForGrid();
117 $pager = $this->
getLayout()->createBlock(\
Magento\Theme\Block\Html\Pager::class);
118 $pager->setAvailableLimit([$availableLimit => $availableLimit])->setCollection($itemsCollection);
120 $itemsCollection->load();
132 public function getItemsForGrid()
134 if (!$this->itemsCollection) {
136 $itemCollection = $this->itemCollectionFactory->create();
138 $itemCollection->setQuote($this->
getQuote());
139 $itemCollection->addFieldToFilter(
'parent_item_id', [
'null' =>
true]);
140 $this->joinAttributeProcessor->process($itemCollection);
142 $this->itemsCollection = $itemCollection;
144 return $this->itemsCollection;
153 if (!$this->isPagerDisplayedOnPage()) {
154 return parent::getItems();
156 return $this->getItemsForGrid()->getItems();
165 private function isPagerDisplayedOnPage()
167 if (!$this->isPagerDisplayed) {
168 $availableLimit = (int)$this->_scopeConfig->getValue(
169 self::XPATH_CONFIG_NUMBER_ITEMS_TO_DISPLAY_PAGER,
172 $this->isPagerDisplayed = !$this->getCustomItems() && $availableLimit < $this->
getItemsCount();
174 return $this->isPagerDisplayed;
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Catalog\Model\ResourceModel\Url $catalogUrlBuilder, \Magento\Checkout\Helper\Cart $cartHelper, \Magento\Framework\App\Http\Context $httpContext, \Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory $itemCollectionFactory, \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor, array $data=[])
getData($key='', $index=null)
const XPATH_CONFIG_NUMBER_ITEMS_TO_DISPLAY_PAGER