/** * @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); }
public function testGetLimit() { $this->assertNull($this->toolbar->getLimit()); $_COOKIE[Toolbar::LIMIT_COOKIE_NAME] = 'limitCookie'; $this->assertEquals('limitCookie', $this->toolbar->getLimit()); }
/** * @dataProvider stringParamProvider * @param $param */ public function testGetLimit($param) { $this->requestMock->expects($this->once())->method('getParam')->with(Toolbar::LIMIT_PARAM_NAME)->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getLimit()); }
/** * Get specified products limit display per page * * @return string */ public function getLimit() { $limit = $this->_getData('_current_limit'); if ($limit) { return $limit; } $limits = $this->getAvailableLimit(); $defaultLimit = $this->getDefaultPerPageValue(); if (!$defaultLimit || !isset($limits[$defaultLimit])) { $keys = array_keys($limits); $defaultLimit = $keys[0]; } $limit = $this->_toolbarModel->getLimit(); if (!$limit || !isset($limits[$limit])) { $limit = $defaultLimit; } if ($limit != $defaultLimit) { $this->_memorizeParam('limit_page', $limit); } $this->setData('_current_limit', $limit); return $limit; }
/** * @dataProvider stringParamProvider * @param $param */ public function testGetLimit($param) { $this->cookieManagerMock->expects($this->once())->method('getCookie')->with(Toolbar::LIMIT_COOKIE_NAME)->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getLimit()); }