Куда именно в catalog/controller/module/htmlmodule.php
<?php class ControllerModuleMyModule extends Controller { private $_name = 'mymodule'; protected function index() { $this->language->load('module/' . $this->_name); $this->data['heading_title'] = $this->language->get('heading_title'); $this->load->model('localisation/language'); $languages = $this->model_localisation_language->getLanguages(); foreach ($languages as $language) { if (isset($this->request->post['mymodule_code' . $language['language_id']])) { $this->data['mymodule_code' . $language['language_id']] = $this->request->post['mymodule_code' . $language['language_id']]; } else { $this->data['mymodule_code' . $language['language_id']] = $this->config->get('mymodule_code' . $language['language_id']); } } $this->data['code'] = html_entity_decode($this->config->get('mymodule_code' . $this->config->get('config_language_id'))); foreach ($languages as $language) { if (isset($this->request->post['mymodule_title' . $language['language_id']])) { $this->data['mymodule_title' . $language['language_id']] = $this->request->post['mymodule_title' . $language['language_id']]; } else { $this->data['mymodule_title' . $language['language_id']] = $this->config->get('mymodule_title' . $language['language_id']); } } $this->data['title'] = $this->config->get($this->_name . '_title' . $this->config->get('config_language_id')); $this->data['header'] = $this->config->get( $this->_name . '_header'); $this->data['oformlenie'] = $this->config->get( $this->_name . '_oformlenie'); $this->id = $this->_name; $tmpl = '/template/module/' . $this->_name . '.tpl'; $tmplhome = '/template/module/' . $this->_name . '_home.tpl'; if( !$this->data['title'] ) { //если мы ничего не ввели в заголовок, то $this->data['title'] = $this->data['heading_title']; // $title присвается название модуля } if( !$this->data['header'] ) { //если заголовок выключен, то $this->data['title'] = ''; // $title пустая. } if ($this->config->get('mymodule_position') == 'home') { if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $tmplhome)) { $this->template = $this->config->get('config_template') . $tmplhome; } else { $this->template = 'default' . $tmplhome; } } else { if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $tmpl)) { $this->template = $this->config->get('config_template') . $tmpl; } else { $this->template = 'default' . $tmpl; } } $this->render(); }}?>
Вставлять это:
$this->load->model('catalog/category'); $this->data['categories'] = array(); $results = $this->model_catalog_category->getCategories(0); foreach ($results as $result) { if ($result['image']) { $image = $result['image']; } else { $image = 'no_image.jpg'; } $this->data['categories'][] = array( 'name' => $result['name'], 'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $result['category_id']), 'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')) ); }
Может какие еще переменные менять? А то пытался просто вставить по разному, выходит ошибка.
Еще же есть admin/controller/module/htmlmodule.php , тут надо что-то менять?
Полазил на Opencart.com и нашел
http://www.opencart.com/index.php?route ... order=DESC
такой модуль Category Product Home
Может его легче приспособить? Но он выдает только определенные категории, а все не выдает.
Вот код его модулей
catalogcontrollermodulecategoryproducthome.php
<?php class ControllerModulecategoryproducthome extends Controller { protected $category_id = 0; protected $path = array(); protected function index() { $this->language->load('module/categoryproducthome'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->load->model('catalog/product'); $this->load->model('catalog/review'); $this->load->model('tool/seo_url'); $this->load->model('tool/image'); $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart'); $this->data['heading_title']=$this->config->get('categoryproducthome_heading'); $this->data['products'] = array(); $results = $this->model_catalog_product->getProductsByCategoryId($this->config->get('categoryproducthome_category'),'p.sort_order', 'ASC', 0, $this->config->get('categoryproducthome_limit')); foreach ($results as $result) { if ($result['image']) { $image = $result['image']; } else { $image = 'no_image.jpg'; } if ($this->config->get('config_review')) { $rating = $this->model_catalog_review->getAverageRating($result['product_id']); } else { $rating = false; } $special = FALSE; $discount = $this->model_catalog_product->getProductDiscount($result['product_id']); if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $this->model_catalog_product->getProductSpecial($result['product_id']); if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $this->model_catalog_product->getProductOptions($result['product_id']); if ($options) { $add = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']); } else { $add = HTTPS_SERVER . 'index.php?route=checkout/cart&product_id=' . $result['product_id']; } $this->data['products'][] = array( 'product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'options' => $options, 'special' => $special, 'image' => $this->model_tool_image->resize($image, 38, 38), 'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')), 'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']), 'add' => $add ); } if (!$this->config->get('config_customer_price')) { $this->data['display_price'] = TRUE; } elseif ($this->customer->isLogged()) { $this->data['display_price'] = TRUE; } else { $this->data['display_price'] = FALSE; } //$this->data['categoryproducthome'] = $this->getProducts($this->config->get('categoryproducthome_category'),$this->config->get('categoryproducthome_limit')); $this->id = 'categoryproducthome'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/categoryproducthome.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/categoryproducthome.tpl'; } else { $this->template = 'default/template/module/categoryproducthome.tpl'; } $this->render(); } protected function getProducts($category_id, $limit=20) { $categoryproducthome = array(); $category_id = array_shift($this->path); $results = $this->model_catalog_product->getProductsByCategoryId($category_id); $i=0; foreach ($results as $result) { if (!$current_path) { $new_path = $result['category_id']; } else { $new_path = $current_path . '_' . $result['category_id']; } if ($result['image']) { $image = $result['image']; } else { $image = 'no_image.jpg'; } if ($this->category_id == $result['category_id']) { $categoryproducthome[$i]['href'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path); } else { $categoryproducthome[$i]['href'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path); } $categoryproducthome[$i]['thumb'] = $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')); $categoryproducthome[$i]['name'] = $result['name']; $i++; } return $categoryproducthome; } }?>
И второй admincontrollermodulecategoryproducthome.php
<?phpclass ControllerModulecategoryproducthome extends Controller { private $error = array(); public function index() { $this->load->language('module/categoryproducthome'); $this->document->title = $this->language->get('heading_title'); $this->load->model('setting/setting'); $this->load->model('catalog/category'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) { $this->model_setting_setting->editSetting('categoryproducthome', $this->request->post); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect(HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token']); } $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_enabled'] = $this->language->get('text_enabled'); $this->data['text_disabled'] = $this->language->get('text_disabled'); $this->data['text_left'] = $this->language->get('text_left'); $this->data['text_right'] = $this->language->get('text_right'); $this->data['entry_position'] = $this->language->get('entry_position'); $this->data['entry_category'] = $this->language->get('entry_category'); $this->data['entry_status'] = $this->language->get('entry_status'); $this->data['entry_limit'] = $this->language->get('entry_limit'); $this->data['entry_headingtitle'] = $this->language->get('entry_headingtitle'); $this->data['entry_sort_order'] = $this->language->get('entry_sort_order'); $this->data['button_save'] = $this->language->get('button_save'); $this->data['button_cancel'] = $this->language->get('button_cancel'); $results = $this->model_catalog_category->getCategories(0); foreach ($results as $result) { $this->data['categories'][] = array( 'category_id' => $result['category_id'], 'name' => $result['name'] ); } if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->document->breadcrumbs = array(); $this->document->breadcrumbs[] = array( 'href' => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'], 'text' => $this->language->get('text_home'), 'separator' => FALSE ); $this->document->breadcrumbs[] = array( 'href' => HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token'], 'text' => $this->language->get('text_module'), 'separator' => ' :: ' ); $this->document->breadcrumbs[] = array( 'href' => HTTPS_SERVER . 'index.php?route=module/categoryproducthome&token=' . $this->session->data['token'], 'text' => $this->language->get('heading_title'), 'separator' => ' :: ' ); $this->data['action'] = HTTPS_SERVER . 'index.php?route=module/categoryproducthome&token=' . $this->session->data['token']; $this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token']; if (isset($this->request->post['categoryproducthome_position'])) { $this->data['categoryproducthome_position'] = $this->request->post['categoryproducthome_position']; } else { $this->data['categoryproducthome_position'] = $this->config->get('categoryproducthome_position'); } if (isset($this->request->post['categoryproducthome_category'])) { $this->data['categoryproducthome_category'] = $this->request->post['categoryproducthome_category']; } else { $this->data['categoryproducthome_category'] = $this->config->get('categoryproducthome_category'); } if (isset($this->request->post['categoryproducthome_heading'])) { $this->data['categoryproducthome_heading'] = $this->request->post['categoryproducthome_heading']; } else { $this->data['categoryproducthome_heading'] = $this->config->get('categoryproducthome_heading'); } if (isset($this->request->post['categoryproducthome_limit'])) { $this->data['categoryproducthome_limit'] = $this->request->post['categoryproducthome_limit']; } else { $this->data['categoryproducthome_limit'] = $this->config->get('categoryproducthome_limit'); } if (isset($this->request->post['categoryproducthome_status'])) { $this->data['categoryproducthome_status'] = $this->request->post['categoryproducthome_status']; } else { $this->data['categoryproducthome_status'] = $this->config->get('categoryproducthome_status'); } if (isset($this->request->post['categoryproducthome_sort_order'])) { $this->data['categoryproducthome_sort_order'] = $this->request->post['categoryproducthome_sort_order']; } else { $this->data['categoryproducthome_sort_order'] = $this->config->get('categoryproducthome_sort_order'); } $this->template = 'module/categoryproducthome.tpl'; $this->children = array( 'common/header', 'common/footer' ); $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression')); } private function validate() { if (!$this->user->hasPermission('modify', 'module/categoryproducthome')) { $this->error['warning'] = $this->language->get('error_permission'); } if (!$this->error) { return TRUE; } else { return FALSE; } }}?>
Как я понимаю, тут будет легче это реализовать.