private function prepareSortOrders()
{
$sortOrders = [];
$useProductuctLimitation = isset($this->_productLimitationFilters['sortParams']);
foreach ($this->_orders as $attribute => $direction) {
$sortParams = ['direction' => $direction];
if ($useProductuctLimitation && isset($this->_productLimitationFilters['sortParams'][$attribute])) {
$sortField = $this->_productLimitationFilters['sortParams'][$attribute]['sortField'];
$sortParams = array_merge($sortParams, $this->_productLimitationFilters['sortParams'][$attribute]);
} elseif ($attribute == 'price') {
// Change the price sort field to the nested price field.
$sortField = 'price.price';
$sortParams['nestedPath'] = 'price';
// Ensure we sort on the position field of the current customer group.
$customerGroupId = $this->_productLimitationFilters['customer_group_id'];
$sortParams['nestedFilter'] = ['price.customer_group_id' => $customerGroupId];
}
$sortField = $this->mapFieldName($attribute);
$sortOrders[$sortField] = $sortParams;
}
return $sortOrders;
}