public function getResourcesFromFavorites() { // with random order is not possible to order by another field $resources = null; if (BFCHelper::CountFavourites() > 0) { // only if there are unit in favorites $params = $this->getState('params'); $options = array('path' => $this->urlResources, 'data' => array('$format' => 'json')); $this->applyDefaultFilter($options); $filterFav = ''; $tmpFav = BFCHelper::GetFavourites(); foreach ($tmpFav as $key => $value) { if (!empty($tmpFav[$key])) { $this->helper->addFilter($filterFav, '(OnSellUnitId eq ' . $tmpFav[$key] . ')', 'or'); } } if ($filterFav != '') { if ($options['data']['$filter'] != '') { $options['data']['$filter'] .= " and (" . $filterFav . ")"; } } // get only enabled merchants because disabled are of no use // // adding other ordering to allow grouping // $options['data']['$orderby'] = 'Created desc'; // $options['data']['$orderby'] = "IsShowcase desc, IsForeground desc, Created desc"; // if (isset($ordering)) { // $options['data']['$orderby'] .= ", " . $ordering . ' ' . strtolower($direction); // } $url = $this->helper->getQuery($options); $r = $this->helper->executeQuery($url); if (isset($r)) { $res = json_decode($r); $resources = $res->d->results ?: $res->d; } } return $resources; }