Exemplo n.º 1
0
 /**
  * @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);
 }
Exemplo n.º 2
0
 public function testGetDirection()
 {
     $this->assertNull($this->toolbar->getDirection());
     $_COOKIE[Toolbar::DIRECTION_COOKIE_NAME] = 'directionCookie';
     $this->assertEquals('directionCookie', $this->toolbar->getDirection());
 }
Exemplo n.º 3
0
 /**
  * @dataProvider stringParamProvider
  * @param $param
  */
 public function testGetDirection($param)
 {
     $this->requestMock->expects($this->once())->method('getParam')->with(Toolbar::DIRECTION_PARAM_NAME)->will($this->returnValue($param));
     $this->assertEquals($param, $this->toolbarModel->getDirection());
 }
Exemplo n.º 4
0
 /**
  * Retrieve current direction
  *
  * @return string
  */
 public function getCurrentDirection()
 {
     $dir = $this->_getData('_current_grid_direction');
     if ($dir) {
         return $dir;
     }
     $directions = ['asc', 'desc'];
     $dir = strtolower($this->_toolbarModel->getDirection());
     if (!$dir || !in_array($dir, $directions)) {
         $dir = $this->_direction;
     }
     if ($dir != $this->_direction) {
         $this->_memorizeParam('sort_direction', $dir);
     }
     $this->setData('_current_grid_direction', $dir);
     return $dir;
 }
Exemplo n.º 5
0
 /**
  * @dataProvider stringParamProvider
  * @param $param
  */
 public function testGetDirection($param)
 {
     $this->cookieManagerMock->expects($this->once())->method('getCookie')->with(Toolbar::DIRECTION_COOKIE_NAME)->will($this->returnValue($param));
     $this->assertEquals($param, $this->toolbarModel->getDirection());
 }