Рекомендуемые

This commit is contained in:
Konstantin
2026-05-30 14:59:49 +03:00
parent 0e8a0f3b0c
commit 6a847ab7b5
4 changed files with 80 additions and 0 deletions
@@ -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');