Jump to content

Order Manufacturers/Brands by the products


Recommended Posts

Hi Steven,

 

You need to change the Manufacturer::getManufacturers() function realisation

Please, view the example:

 

Manufacturer::getManufacturers(){
....
self::sortArrayByAttribute($manufacturers, 'nb_products');
....
}

public static function sortArrayByAttribute(&$array, $attribute, $type = 'desc')
{
 return usort($array, create_function('$a, $b','return $a["' . $attribute . '"] ' . ($type == 'asc' ? '>' : '<') . ' $b["' . $attribute . '"];'));
}

 

Best regards

Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...