OpenCart 🇺🇦

Схема

public mixed autocomplete ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$json = array();

if (isset($this->request->get['filter_name'])) {
	$this->load->model('catalog/category');

	$data = array(
		'filter_name' => $this->request->get['filter_name'],
		'start'       => 0,
		'limit'       => 20
	);

	$results = $this->model_catalog_category->getCategories($data);

	foreach ($results as $result) {
		$json[] = array(
			'category_id' => $result['category_id'], 
			'name'        => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'))
		);
	}		
}

$sort_order = array();

foreach ($json as $key => $value) {
	$sort_order[$key] = $value['name'];
}

array_multisort($sort_order, SORT_ASC, $json);

$this->response->setOutput(json_encode($json));