/**
  * @param \Magento\Framework\App\Action\Action $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $this->httpContext->setValue(Data::CONTEXT_CATALOG_SORT_DIRECTION, $this->toolbarModel->getDirection(), \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION);
     $this->httpContext->setValue(Data::CONTEXT_CATALOG_SORT_ORDER, $this->toolbarModel->getOrder(), $this->productListHelper->getDefaultSortField());
     $this->httpContext->setValue(Data::CONTEXT_CATALOG_DISPLAY_MODE, $this->toolbarModel->getMode(), $this->productListHelper->getDefaultViewMode());
     $this->httpContext->setValue(Data::CONTEXT_CATALOG_LIMIT, $this->toolbarModel->getLimit(), $this->productListHelper->getDefaultLimitPerPageValue($this->productListHelper->getDefaultViewMode()));
     return $proceed($request);
 }
Beispiel #2
0
 public function testAroundDispatchHasSortDirection()
 {
     $this->toolbarModelMock->expects($this->exactly(1))->method('getDirection')->will($this->returnValue('asc'));
     $this->toolbarModelMock->expects($this->once())->method('getOrder')->will($this->returnValue('Name'));
     $this->toolbarModelMock->expects($this->once())->method('getMode')->will($this->returnValue('list'));
     $this->toolbarModelMock->expects($this->once())->method('getLimit')->will($this->returnValue(array(1 => 1, 2 => 2)));
     $this->productListHelperMock->expects($this->once())->method('getDefaultSortField')->will($this->returnValue('Field'));
     $this->productListHelperMock->expects($this->exactly(2))->method('getDefaultViewMode')->will($this->returnValue('grid'));
     $this->productListHelperMock->expects($this->once())->method('getDefaultLimitPerPageValue')->will($this->returnValue(array(10 => 10)));
     $this->httpContextMock->expects($this->exactly(4))->method('setValue')->will($this->returnValueMap(array(array(\Magento\Catalog\Helper\Data::CONTEXT_CATALOG_SORT_DIRECTION, 'asc', \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION, $this->httpContextMock), array(\Magento\Catalog\Helper\Data::CONTEXT_CATALOG_SORT_ORDER, 'Name', 'Field', $this->httpContextMock), array(\Magento\Catalog\Helper\Data::CONTEXT_CATALOG_DISPLAY_MODE, 'list', 'grid', $this->httpContextMock), array(\Magento\Catalog\Helper\Data::CONTEXT_CATALOG_LIMIT, array(1 => 1, 2 => 2), array(10 => 10)))));
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
 public function testGetPagerHtml()
 {
     $limit = 10;
     $this->layout->expects($this->once())->method('getChildName')->will($this->returnValue('product_list_toolbar_pager'));
     $this->layout->expects($this->once())->method('getBlock')->will($this->returnValue($this->pagerBlock));
     $this->productListHelper->expects($this->exactly(2))->method('getAvailableLimit')->will($this->returnValue([10 => 10, 20 => 20]));
     $this->model->expects($this->once())->method('getLimit')->will($this->returnValue($limit));
     $this->pagerBlock->expects($this->once())->method('setUseContainer')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setShowPerPage')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setShowAmounts')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setFrameLength')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setJump')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setLimit')->with($limit)->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setCollection')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('toHtml')->will($this->returnValue(true));
     $this->assertTrue($this->block->getPagerHtml());
 }
Beispiel #4
0
 /**
  * Get order field
  *
  * @return null|string
  */
 protected function getOrderField()
 {
     if ($this->_orderField === null) {
         $this->_orderField = $this->_productListHelper->getDefaultSortField();
     }
     return $this->_orderField;
 }
Beispiel #5
0
 /**
  * Retrieve available limits for current view mode
  *
  * @return array
  */
 public function getAvailableLimit()
 {
     return $this->_productListHelper->getAvailableLimit($this->getCurrentMode());
 }