Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

[Решено] Не работает модуль ПРОИЗВОДИТЕЛИ (страница не найдена)


Athen

Recommended Posts

Доброго времени суток. Всем!!!

Подобный вопрос на этом форуме обсуждался . И тогда его вроде решили. 

Но!

Сейчас такая картина :

меняю product  на info   в manufacturer.php  и в  seo_pro.php

- не работает.

Получаю ссылки : рабочая из футера "производители " : http://uakotel.com.ua/index.php?route=product/manufacturer/info&manufacturer_id=19

и не рабочая из модуля : http://uakotel.com.ua/index.php?route=product/manufacturer/product&manufacturer_id=19

(прим. модуль сеопро устанавливался после создания категорий, и когда там прописывал адрес - страницу тоже не находило, так что урлы категорий и производителей не чпу)

_________________________________________________________

manufacturer.php :

----------

<?php  
class ControllerModuleManufacturer extends Controller {
protected function index($setting) {
$this->language->load('module/manufacturer');


     $this->data['heading_title'] = $this->language->get('heading_title');


if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}


if (isset($parts[0])) {
$this->data['manufacturer_id'] = $parts[0];
} else {
$this->data['manufacturer_id'] = 0;
}


if (isset($parts[1])) {
$this->data['child_id'] = $parts[1];
} else {
$this->data['child_id'] = 0;
}


$this->load->model('catalog/manufacturer');
$this->load->model('catalog/product');
$this->load->model('tool/image');
/*
$this->load->model('catalog/manufacturer');
$m = $this->model_catalog_manufacturer->getManufacturers(0);
var_dump($m);
*/
$this->data['manufactureres'] = array();


$results = $this->model_catalog_manufacturer->getManufacturers(0);
foreach($results as $result)
{


if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}


$this->data['manufactureres'][] = array(
'thumb' => $this->model_tool_image->resize($image,$setting['image_width'], $setting['image_height']),
'manufacturer_id' => $result['manufacturer_id'],
'name'        => $result['name'] ,
'href'        => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $result['manufacturer_id'])




//route=product/manufacturer/product&manufacturer_id=6
);
}
/*
foreach ($manufactureres as $manufacturer) {
$children_data = array();


$children = $this->model_catalog_manufacturer->getManufacturers($manufacturer['manufacturer_id']);


foreach ($children as $child) {
$data = array(
'filter_manufacturer_id'  => $child['manufacturer_id'],
'filter_sub_manufacturer' => true
); 


$product_total = $this->model_catalog_product->getTotalProducts($data);


$children_data[] = array(
'manufacturer_id' => $child['manufacturer_id'],
'name'        => $child['name'] . ' (' . $product_total . ')',
'href'        => $this->url->link('product/manufacturer', 'path=' . $manufacturer['manufacturer_id'] . '_' . $child['manufacturer_id']) 
); 
}


$data = array(
'filter_manufacturer_id'  => $manufacturer['manufacturer_id'],
'filter_sub_manufacturer' => true 
); 


$product_total = $this->model_catalog_product->getTotalProducts($data);


$this->data['manufactureres'][] = array(
'manufacturer_id' => $manufacturer['manufacturer_id'],
'name'        => $manufacturer['name'] . ' (' . $product_total . ')',
'children'    => $children_data,
'href'        => $this->url->link('product/manufacturer', 'path=' . $manufacturer['manufacturer_id'])
);
}
*/
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/manufacturer.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/manufacturer.tpl';
} else {
$this->template = 'default/template/module/manufacturer.tpl';
}


$this->render();
   }
}
?>
______________________________
seo_pro.php
------------------
<?php
class ControllerCommonSeoPro extends Controller {
private $cache_data = null;
private $languages = array();
private $config_language;


public function __construct($registry) {
parent::__construct($registry);
$this->cache_data = $this->cache->get('seo_pro');
if (!$this->cache_data) {
$query = $this->db->query("SELECT LOWER(`keyword`) as 'keyword', `query` FROM " . DB_PREFIX . "url_alias");
$this->cache_data = array();
foreach ($query->rows as $row) {
$this->cache_data['keywords'][$row['keyword']] = $row['query'];
$this->cache_data['queries'][$row['query']] = $row['keyword'];
}
$this->cache->set('seo_pro', $this->cache_data);
}


$query = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_language'");
$this->config_language = $query->row['value'];


$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language WHERE status = '1'");


foreach ($query->rows as $result) {
$this->languages[$result['code']] = $result;
}


}


public function index() {


// language
$code = $this->config_language;


if(isset($this->request->get['_route_'])) {
$tokens = explode('/', $this->request->get['_route_']);


if(array_key_exists($tokens[0], $this->languages)) {
$code = $tokens[0];
$this->request->get['_route_'] = substr($this->request->get['_route_'], strlen($code) + 1);
}


if(trim($this->request->get['_route_']) == '' || trim($this->request->get['_route_']) == 'index.php') {
unset($this->request->get['_route_']);
}
}




if(!isset($this->session->data['language']) || $this->session->data['language'] != $code) {
$this->session->data['language'] = $code;
}


if(!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) {
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
}


$this->config->set('config_language_id', $this->languages[$code]['language_id']);
$this->config->set('config_language', $this->languages[$code]['code']);


$language = new Language($this->languages[$code]['directory']);
$language->load($this->languages[$code]['filename']);
$this->registry->set('language', $language);




// Add rewrite to url class
if ($this->config->get('config_seo_url')) {
$this->url->addRewrite($this);
} else {
return;
}


// Decode URL
if (!isset($this->request->get['_route_'])) {
$this->validate();
} else {
$route = $this->request->get['_route_'];
unset($this->request->get['_route_']);
$parts = explode('/', trim(utf8_strtolower($route), '/'));
list($last_part) = explode('.', array_pop($parts));
array_push($parts, $last_part);


$rows = array();
foreach ($parts as $keyword) {
if (isset($this->cache_data['keywords'][$keyword])) {
$rows[] = array('keyword' => $keyword, 'query' => $this->cache_data['keywords'][$keyword]);
}
}


if (count($rows) == sizeof($parts)) {
$queries = array();
foreach ($rows as $row) {
$queries[utf8_strtolower($row['keyword'])] = $row['query'];
}


reset($parts);
foreach ($parts as $part) {
$url = explode('=', $queries[$part], 2);


if ($url[0] == 'category_id') {
if (!isset($this->request->get['path'])) {
$this->request->get['path'] = $url[1];
} else {
$this->request->get['path'] .= '_' . $url[1];
}
} elseif (count($url) > 1) {
$this->request->get[$url[0]] = $url[1];
}
}
} else {
$this->request->get['route'] = 'error/not_found';
}


if (isset($this->request->get['product_id'])) {
$this->request->get['route'] = 'product/product';
if (!isset($this->request->get['path'])) {
$path = $this->getPathByProduct($this->request->get['product_id']);
if ($path) $this->request->get['path'] = $path;
}
} elseif (isset($this->request->get['path'])) {
$this->request->get['route'] = 'product/category';
} elseif (isset($this->request->get['manufacturer_id'])) {
$this->request->get['route'] = 'product/manufacturer/product';
} elseif (isset($this->request->get['information_id'])) {
$this->request->get['route'] = 'information/information';
} else {
if (isset($queries[$parts[0]])) {
$this->request->get['route'] = $queries[$parts[0]];
}
}




$this->validate();


if (isset($this->request->get['route'])) {
return $this->forward($this->request->get['route']);
}
}
}


public function rewrite($link, $code = '') {
if(!$code) {
$code = $this->session->data['language'];
}
if (!$this->config->get('config_seo_url')) return $link;


$seo_url = '';


$component = parse_url(str_replace('&', '&', $link));


$data = array();
parse_str($component['query'], $data);


$route = $data['route'];
unset($data['route']);


switch ($route) {
case 'product/product':
if (isset($data['product_id'])) {
$tmp = $data;
$data = array();
if ($this->config->get('config_seo_url_include_path')) {
$data['path'] = $this->getPathByProduct($tmp['product_id']);
if (!$data['path']) return $link;
}
$data['product_id'] = $tmp['product_id'];
if (isset($tmp['tracking'])) {
$data['tracking'] = $tmp['tracking'];
}
}
break;


case 'product/category':
if (isset($data['path'])) {
$category = explode('_', $data['path']);
$category = end($category);
$data['path'] = $this->getPathByCategory($category);
if (!$data['path']) return $link;
}
break;


case 'product/product/review':
case 'information/information/info':
return $link;
break;


default:
break;
}


if ($component['scheme'] == 'https') {
$link = $this->config->get('config_ssl');
} else {
$link = $this->config->get('config_url');
}


if ($code != $this->config_language){
$link .= $code . '/index.php?route=' . $route;
} else{
$link .= 'index.php?route=' . $route;
}


if (count($data)) {
$link .= '&' . urldecode(http_build_query($data, '', '&'));
}


$queries = array();
foreach ($data as $key => $value) {
switch ($key) {
case 'product_id':
case 'manufacturer_id':
case 'category_id':
case 'information_id':
$queries[] = $key . '=' . $value;
unset($data[$key]);
$postfix = 1;
break;


case 'path':
$categories = explode('_', $value);
foreach ($categories as $category) {
$queries[] = 'category_id=' . $category;
}
unset($data[$key]);
break;


default:
break;
}
}


if(empty($queries)) {
$queries[] = $route;
}


$rows = array();
foreach($queries as $query) {
if(isset($this->cache_data['queries'][$query])) {
$rows[] = array('query' => $query, 'keyword' => $this->cache_data['queries'][$query]);
}
}


if(count($rows) == count($queries)) {
$aliases = array();
foreach($rows as $row) {
$aliases[$row['query']] = $row['keyword'];
}
foreach($queries as $query) {
$seo_url .= '/' . rawurlencode($aliases[$query]);
}
}


if ($seo_url == '') return $link;


if($code != $this->config_language) {
$seo_url = $code . '/' . trim($seo_url, '/');
} else {
$seo_url = trim($seo_url, '/');
}


if ($component['scheme'] == 'https') {
$seo_url = $this->config->get('config_ssl') . $seo_url;
} else {
$seo_url = $this->config->get('config_url') . $seo_url;
}


if (isset($postfix)) {
$seo_url .= trim($this->config->get('config_seo_url_postfix'));
} else {
$seo_url .= '/';
}


if(substr($seo_url, -2) == '//') {
$seo_url = substr($seo_url, 0, -1);
}


if (count($data)) {
$seo_url .= '?' . urldecode(http_build_query($data, '', '&'));
}


return $seo_url;
}


private function getPathByProduct($product_id) {
$product_id = (int)$product_id;
if ($product_id < 1) return false;


static $path = null;
if (!is_array($path)) {
$path = $this->cache->get('product.seopath');
if (!is_array($path)) $path = array();
}


if (!isset($path[$product_id])) {
$query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . $product_id . "' ORDER BY main_category DESC LIMIT 1");


$path[$product_id] = $this->getPathByCategory($query->num_rows ? (int)$query->row['category_id'] : 0);


$this->cache->set('product.seopath', $path);
}


return $path[$product_id];
}


private function getPathByCategory($category_id) {
$category_id = (int)$category_id;
if ($category_id < 1) return false;


static $path = null;
if (!is_array($path)) {
$path = $this->cache->get('category.seopath');
if (!is_array($path)) $path = array();
}


if (!isset($path[$category_id])) {
$max_level = 10;


$sql = "SELECT CONCAT_WS('_'";
for ($i = $max_level-1; $i >= 0; --$i) {
$sql .= ",t$i.category_id";
}
$sql .= ") AS path FROM " . DB_PREFIX . "category t0";
for ($i = 1; $i < $max_level; ++$i) {
$sql .= " LEFT JOIN " . DB_PREFIX . "category t$i ON (t$i.category_id = t" . ($i-1) . ".parent_id)";
}
$sql .= " WHERE t0.category_id = '" . $category_id . "'";


$query = $this->db->query($sql);


$path[$category_id] = $query->num_rows ? $query->row['path'] : false;


$this->cache->set('category.seopath', $path);
}


return $path[$category_id];
}


private function validate() {
if (isset($this->request->get['route']) && $this->request->get['route'] == 'error/not_found') {
return;
}
if(empty($this->request->get['route'])) {
$this->request->get['route'] = 'common/home';
}


if (isset($this->request->server['HTTP_X_REQUESTED_WITH']) && strtolower($this->request->server['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return;
}


if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$config_ssl = substr($this->config->get('config_ssl'), 0, $this->strpos_offset('/', $this->config->get('config_ssl'), 3) + 1);
$url = str_replace('&', '&', $config_ssl . ltrim($this->request->server['REQUEST_URI'], '/'));
$seo = str_replace('&', '&', $this->url->link($this->request->get['route'], $this->getQueryString(array('route')), 'SSL'));
} else {
$config_url = substr($this->config->get('config_url'), 0, $this->strpos_offset('/', $this->config->get('config_url'), 3) + 1);
$url = str_replace('&', '&', $config_url . ltrim($this->request->server['REQUEST_URI'], '/'));
$seo = str_replace('&', '&', $this->url->link($this->request->get['route'], $this->getQueryString(array('route')), 'NONSSL'));
}


if (rawurldecode($url) != rawurldecode($seo)) {
header($this->request->server['SERVER_PROTOCOL'] . ' 301 Moved Permanently');


$this->response->redirect($seo);
}
}


private function strpos_offset($needle, $haystack, $occurrence) {
// explode the haystack
$arr = explode($needle, $haystack);
// check the needle is not out of bounds
switch($occurrence) {
case $occurrence == 0:
return false;
case $occurrence > max(array_keys($arr)):
return false;
default:
return strlen(implode($needle, array_slice($arr, 0, $occurrence)));
}
}


private function getQueryString($exclude = array()) {
if (!is_array($exclude)) {
$exclude = array();
}


return urldecode(http_build_query(array_diff_key($this->request->get, array_flip($exclude))));
}
}
?>

Змінено користувачем Tom
Надіслати
Поділитися на інших сайтах


Выключил чпу . 

Получаем :

модуль дополнительно - производители - аристон : http://uakotel.com.ua/index.php?route=product/manufacturer/info&manufacturer_id=19  ( рабочая ссылка)

модуль производители левая колонка - аристон : http://uakotel.com.ua/index.php?route=product/manufacturer/product&manufacturer_id=19  (  Запрашиваемая страница не найдена!)

меняю product  на info   в manufacturer.php  и в  seo_pro.php

- не помогает.

Надіслати
Поділитися на інших сайтах


В контроллере модуля 'Производители' все

$this->url->link('product/manufacturer/product'

Поменять на

$this->url->link('product/manufacturer/info'
Надіслати
Поділитися на інших сайтах

поменял в manufacturer.php  и в  seo_pro.php на info , и заново переписал имена в сео.

Теперь заработало.

Большое спасибо за помощь всем участникам!

Вопрос закрыт!

Надіслати
Поділитися на інших сайтах


Гість
Ця тема закрита для публікації повідомлень.
×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.