Apple Dev
Apple Dev

Reputation: 35

How to sort customer list by using bigcommerce v2 api

How to sort customer list by using bigcommerce v2 api. I made below code.

$filter = array("page" =>$page, "limit" =>50);
$customersList = $this->store->getCustomers($filter);                                   public static function getCustomers($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/customers'. $filter->toQuery(), 'Customer');
    }

First, I want sort first whole list by date_created in desc and then filter it for pagination . To show newly added record first. Please help me to find out solution..

Upvotes: 0

Views: 85

Answers (1)

Alyss
Alyss

Reputation: 1866

There isn't a supported sort from the API, so you'll have to sort the array. Laravel supports array_sort.

$customers = array_values(array_sort($array, function($value)
{
    return $value['date_created'];
}));

https://laravel.com/docs/4.2/helpers#arrays

Upvotes: 1

Related Questions