создал новый модуль поиска по сайту тестовый на основе
существующего, поставил его на главную страницу, отображается нормально,
но после нажатия на кнопку найти меня перебрасывает на страницу собственно модуля
с помощью js и проблема в том, что пишет не может найти эту страницу.
в админке модуль лежит здесь admin/controller/module/search.php
вот код модуля в catalog/controller/module/search.php и catalog/view/theme/default/template/module/search.tpl file соответственно и вопрос - что я не так делаю?
<?php class ControllerModuleSearch extends Controller {
protected function index($setting) {
$this->language->load('module/search');
$this->data['heading_title'] = $this->language->get('heading_title');
if (isset($this->request->get['search_phrase'])) {
$search_phrase = $this->request->get['search_phrase'];
} else {
$search_phrase = '';
}
$url = '';
$this->data['search_phrase'] = $search_phrase;
$this->data['button_cart'] = $this->language->get('button_cart');
//$this->load->model('catalog/search');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$this->data['products'] = array();
$products = $this->model_catalog_product->getProducts();
//var_dump($products);
foreach ($products as $product) {
$product_info = $this->model_catalog_product->getProduct((int) $product['product_id']);
if ($product_info) {
//echo $product['product_id'];
if (strpos($product_info['name'],$search_phrase) !== false) {
echo $product['product_id'];
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], '20', '20');
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);
}
}
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/search.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/search.tpl';
} else {
$this->template = 'default/template/module/search.tpl';
}
$this->response->setOutput($this->render());
}
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<input type="text" name="search_phrase" size="50" value="<?php echo $search_phrase; ?>" placeholder="Поиск"/>
<button class="go_search" type="submit">Найти</button>
</form>
<div class="box-product">
<?php if (count($products)) foreach ($products as $product) { ?>
<div>
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
<?php } ?>
<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
<div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
</div>
<?php } ?>
</div>
</div>
</div>
<script>
$(document).ready(function() {
/* Search */
$('.go_search').bind('click', function () {
url = $('base').attr('href') + 'index.php?route=module/search';
var search = $('input[name=\'search_phrase\']').attr('value');
if (search) {
url += '&search_phrase=' + encodeURIComponent(search);
}
location = url;
});
});
</script>