/**
  * @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
 /**
  * Retrieve widget options in json format
  *
  * @param array $customOptions Optional parameter for passing custom selectors from template
  * @return string
  */
 public function getWidgetOptionsJson(array $customOptions = [])
 {
     $defaultMode = $this->_productListHelper->getDefaultViewMode($this->getModes());
     $options = ['mode' => ToolbarModel::MODE_PARAM_NAME, 'direction' => ToolbarModel::DIRECTION_PARAM_NAME, 'order' => ToolbarModel::ORDER_PARAM_NAME, 'limit' => ToolbarModel::LIMIT_PARAM_NAME, 'modeDefault' => $defaultMode, 'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION, 'orderDefault' => $this->_productListHelper->getDefaultSortField(), 'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode), 'url' => $this->getPagerUrl()];
     $options = array_replace_recursive($options, $customOptions);
     return json_encode(['productListToolbarForm' => $options]);
 }
Beispiel #3
0
 /**
  * Retrieve default per page values
  *
  * @return string (comma separated)
  */
 public function getDefaultPerPageValue()
 {
     if ($this->getCurrentMode() == 'list' && ($default = $this->getDefaultListPerPage())) {
         return $default;
     } elseif ($this->getCurrentMode() == 'grid' && ($default = $this->getDefaultGridPerPage())) {
         return $default;
     }
     return $this->_productListHelper->getDefaultLimitPerPageValue($this->getCurrentMode());
 }