Search Result Sort by SKU (A to Z order)
-
I successfully added below snippets so the search result is sort by SKU (Z to A order). Is there anyway to change sort by SKU to A to Z order?
add_filter( ‘aws_search_results_products’, ‘aws_search_results_products’ );
function aws_search_results_products( $products ) {
usort($products, function ($item1, $item2) {
$a = $item1[‘sku’];
$b = $item2[‘sku’];
if ($a == $b) {
return 0;
}
return ($a < $b) ? 1 : -1;
});
return $products;
}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Search Result Sort by SKU (A to Z order)’ is closed to new replies.