public function afterGetSortOrders(
        RequestMapper $subject,
        $result,
        ContainerConfigurationInterface $containerConfiguration,
        SearchCriteriaInterface $searchCriteria
    ) {
        if ($this->isEnabled($containerConfiguration)) {
            $sortOrders = [];

            if ($containerConfiguration->getName() == "catalog_view_container" && empty($result)) {
                $result['position'] = ['direction' => SortOrderInterface::SORT_ASC];
            }

            foreach ($result as $sortField => $sortParams) {
                if ($sortField == 'price') {
                    $sortParams['nestedFilter'] = ['price.customer_group_id' => $this->customerSession->getCustomerGroupId()];
                } elseif ($sortField == 'position') {
                    $categoryId = $this->getCurrentCategoryId($containerConfiguration, $searchCriteria);
                    $sortParams['nestedFilter'] = ['category.category_id' => $categoryId];
                }

                $sortOrders[$this->getMappingField($containerConfiguration, $sortField)] = $sortParams;
            }

            $result = $sortOrders;
        }

        return $result;
    }
public function afterGetSortOrders(
        RequestMapper $subject,
        $result,
        ContainerConfigurationInterface $containerConfiguration,
        SearchCriteriaInterface $searchCriteria
    ) {
        if ($this->isEnabled($containerConfiguration)) {
            $sortOrders = [];

            if ($containerConfiguration->getName() == "catalog_view_container" && empty($result)) {
                $result['position'] = ['direction' => SortOrderInterface::SORT_ASC];
            }

            foreach ($result as $sortField => $sortParams) {
                if ($sortField == 'price') {
                    $sortParams['nestedFilter'] = ['price.customer_group_id' => $this->customerSession->getCustomerGroupId()];
                } elseif ($sortField == 'position') {
                    $categoryId = $this->getCurrentCategoryId($containerConfiguration, $searchCriteria);
                    $sortParams['nestedFilter'] = ['category.category_id' => $categoryId];
                }

                $sortOrders[$this->getMappingField($containerConfiguration, $sortField)] = $sortParams;
            }

            $result = $sortOrders;
        }

        return $result;
    }
public function afterGetSortOrders ( RequestMapper $ subject , $ result , ContainerConfigurationInterface $ containerConfiguration , SearchCriteriaInterface $ searchCriteria ) { if ( $ this -> isEnabled ( $ containerConfiguration ) ) { $ sortOrders = [ ] ; if ( $ containerConfiguration -> getName ( ) == "catalog_view_container" && empty ( $ result ) ) { $ result [ 'position' ] = [ 'direction' => SortOrderInterface :: SORT_ASC ] ; } foreach ( $ result as $ sortField => $ sortParams ) { if ( $ sortField == 'price' ) { $ sortParams [ 'nestedFilter' ] = [ 'price.customer_group_id' => $ this -> customerSession -> getCustomerGroupId ( ) ] ; } elseif ( $ sortField == 'position' ) { $ categoryId = $ this -> getCurrentCategoryId ( $ containerConfiguration , $ searchCriteria ) ; $ sortParams [ 'nestedFilter' ] = [ 'category.category_id' => $ categoryId ] ; } $ sortOrders [ $ this -> getMappingField ( $ containerConfiguration , $ sortField ) ] = $ sortParams ; } $ result = $ sortOrders ; } return $ result ; }
Post process catalog sort orders.

@SuppressWarnings(PHPMD.UnusedFormalParameter)

@param RequestMapper                   $subject                Request mapper.
@param array                           $result                 Original sort orders.
@param ContainerConfigurationInterface $containerConfiguration Container configuration.
@param SearchCriteriaInterface         $searchCriteria         Search criteria.

@return array[]
Post process catalog sort orders .