/**
* Строим дерево категории
* @param $data
* @param int $rootID
* @return array
*/
protected function buildTree($data, $rootID = 0)
{
$tree = [];
foreach ($data as $id => $node) {
if ($node['parent_id'] == $rootID) {
unset($data[$id]);
$node['childs'] = $this->buildTree($data, $node['id']);
$tree[] = $node;
}
}
return $tree;
}
/**
* Получаю все категории
* @return array
*/
public function getAllCategories()
{
$data = self::find()->asArray()->all();
return $this->buildTree($data);
}
public function getDepartureTime(){
return $this->db->query("SELECT departure_time FROM ".DB_PREFIX."product GROUP BY departure_time ASC");
}
$data['sorts'][] = array(
'text' => $this->language->get('text_departure_time'),
'value' => 'p.departure_time-ASC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=departure_time&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_departure_time'),
'value' => 'p.departure_time-DESC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=departure_time%20%ASC%2c%20arrival_time&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_departure_time'),
'value' => 'p.departure_time-ASC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=departure_time&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_arrival_time'),
'value' => 'p.arrival_time-DESC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=arrival_time&order=DESC' . $url)
);