Рекомендуемые
This commit is contained in:
@@ -156,6 +156,27 @@ class ControllerExtensionModuleFeatured extends Controller {
|
||||
$this->response->setOutput($this->load->view('extension/module/featured', $data));
|
||||
}
|
||||
|
||||
public function random() {
|
||||
$json = array();
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$limit = isset($this->request->get['limit']) ? (int)$this->request->get['limit'] : 5;
|
||||
$exclude = isset($this->request->get['exclude']) ? $this->request->get['exclude'] : array();
|
||||
|
||||
$results = $this->model_catalog_product->getRandomProducts($limit, $exclude);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$json[] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'name' => html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')
|
||||
);
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/module/featured')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
|
||||
Reference in New Issue
Block a user