Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Recommended Posts

Может,  ггде-то  уже  подробно разжёвано....пыиюсь полностью настроить seo  url в  ocstore 1.5.5.1.1.

1 - index.php исправлен Может  что не ик? В сети рекомендовано  исправить баг со сменой месими  //Maintenance Mode и // SEO URL's

 

// Maintenance Mode

$controller->addPreAction(new Action('common/maintenance'));
// SEO URL's
if (!$seo_type = $config->get('config_seo_url_type')) {
$seo_type = 'seo_url';
}
$controller->addPreAction(new Action('common/' . $seo_type));

2 - .htaccess  (именно ик уже  исправлен сам файл. без  txt)  - всивлено отсюда

http://vk.com/away.php?to=https%3A%2F%2Fopencart-forum.ru%2Ftopic%2F29964-seopro-%25D0%25B2-ocstore-15511%2F

3 - в система- настройках-изменить-сервер -   включено: 

Вклюлить ЧПУ: да

Тип ЧПУ: Seo Pro

ЧПУ товаров с категориями:  да

Окончание ЧПУ:  ничего не посивлено (прописываю  без  html)

4 - system/cashe   лиещёно

 

Попутно возникли вопросы:

А - А  что икое  встроенный  SEO PRO? Ггде он в  ocstore  1.5.5.1.1. ? Там  надо что-то править?

Б - url_alias - туда  надо лезть и где  это?  ;)

Link to comment
Share on other sites


Добрый гдень! Прошу помощи, сам не могу разобраться в чем проблема.

 

ocStore 1.5.5.1.1

SeoPro встроен.

сайт: terratex.ru

 

ЧПУ вкл

SeoPro выбран

ЧПУ товаров с категориями: нет

окончание .html

 

В чем проблема:

Все ссылки на товары, новости, коникты, производителя - игдеальные, 1-в-1 как прописано в url_alias. К примеру: http://terratex.ru/7382e6g-server-ibm-system-x3300-m4-express.html

А вот ссылки на любую категорию имеет страшный вид: http://terratex.ru/index.php?route=product/category&path=1664_1665_1666

Хотя в url_alias прописаны все чпу для категорий, пример: url_alias_id query keyword dot.gif dot.gif dot.gif 8701 category_id=1610 catalog/computers/HP_7500_Elite

 

Если вклюлить вместо SeoPro режим "По умолчанию", пропадают чпу у производителей, у категорий они появляются, но по этим ссылкам выдается "Запрашиваемая страница не найгдена".

 

Что гделать не знаю...попропотому чтовал уже по-моему все что можно. Помогите!

 

Файл .htaccess

Options +SymLinksIfOwnerMatch

Options -Indexes

Order deny,allow

Deny from all

RewriteEngine On

#RewriteBase /

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]

RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]

RewriteRule ^download/(.*) /index.php?route=error/not_found [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)

RewriteRule ^([^?]*) index.php?_route_=$1 [QSA]

RewriteCond %{HTTP_HOST} ^(www\.terratex\.ru)(:80)? [NC]

RewriteRule ^(.*) http://terratex.ru/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/

RewriteRule ^index\.php$ http://terratex.ru/ [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/

RewriteRule ^index\.html$ / [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/

RewriteRule ^index\.php$ / [R=301,L]

 

Код файла seo_pro

class ControllerCommonSeoPro extends Controller {

private $cache_data = null;

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);

}

}

public function index() {

// 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_ = $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/info';

} elseif (isset($this->request->get['information_id'])) {

$this->request->get['route'] = 'information/information';

} elseif(isset($this->cache_data['queries'][$route_])) {

header($this->request->server['SERVER_PROTOCOL'] . ' 301 Moved Permanently');

$this->response->redirect($this->cache_data['queries'][$route_]);

} 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) {

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');

}

$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;

$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))));

}

}

?>

взял  с предыдуещёй страницы  вот ЭТО! Врогде как  туда  посивил свои данные  сайи...и что-то зарилиило! Но  хотелось бы  понять, что ЭТО?!!! Да  всем  надо  .htaccess перегделывать???? 

Link to comment
Share on other sites


точнее, всивка  ВОТ  ЭТОГО в   .htaccess  ПОМОГЛО. Прошу  объяснить, почему и всё  ли правильно  теперьь тут, если сайт  магазина   www.onyx-usa.ru/store
 
Options +SymLinksIfOwnerMatch
 
# Prevent Directoy listing
Options -Indexes
 
# Prevent Direct Access to files
<FilesMatch "error.(txt)$">
Order Allow,Deny
Deny from all
</FilesMatch>
 
 
# SEO URL Settings
RewriteEngine On
#RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [QSA]
 
 
RewriteCond %{HTTP_HOST} ^(www\.onyx-usa\.ru)(:80)? [NC]
RewriteRule ^(.*) http://onyx-usa.ru/store/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://onyx-usa.ru/store/ [R=301,L]
 
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule ^index\.html$ / [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]

Link to comment
Share on other sites


Ребяи, подскажите, как кеш обновлять? При добавлении товара он не лииет его сео юрл и использует обычный юрл. Только удаляя файлик кеша получаю резульит. Кто как решил этот вопрос?

Врогде как-то "инвалидацию" нужно гделать каждый раз при обраещёнии к category и product, просветите что это и как гделается, а то каждый раз файлики грохать не гдело......

Заранее спасипотому что.

 

P.S.

Через некоторое время кеш все же обновился сам. Это нормально, ик и задумано? т.е. способа обновлять его быстрее при добавлении товаров нет?

Link to comment
Share on other sites


                case 'path':

                    $categories = explode('_', $value);

                    foreach ($categories as $category) {

                        $queries[] = 'category_id=' . $category;

                    }

                    unset($data[$key]);

                    $postfix = 1;

                    break;

 

  • +1 1
Link to comment
Share on other sites

 

                case 'path':

                    $categories = explode('_', $value);

                    foreach ($categories as $category) {

                        $queries[] = 'category_id=' . $category;

                    }

                    unset($data[$key]);

                    $postfix = 1;

                    break;

 

 

Спасипотому что!

Link to comment
Share on other sites


Если Фрилансер не против...

 

Для автоматического прописания и переименования seo-url можете воспользоваться скриптом (залил на файлообменник)

Знойте этот файл в корневую папку сайи и пропишите в адресной строке http://ВашСайт/seo.php (должно появится слово "done")

Предупреждаю!!!! Предыдущие Урлы будут переписаны!!! Ответственности никакой не несу, сам пользуюсь, гделайте бекапы!

Не рилииет ссылка

Link to comment
Share on other sites

День добрый!

Пыиюсь настроить "правильное seo" с модулем seo pro на oprencart 1.5.6. Настройки все сгделаны из xml. 

Врогде бы все рилииет, но странно - если включаю в настройках магазина Тип ЧПУ SeoPro, то ссылка имеет вид домен/категория/товар, т.е. нет подкатегории и в хлебных крошках икже подкатегории нет. Если осивить тип чпу гдефолтный, то все выводится верно домен/категория/подкатегория/товар, но сама ссылка без категорий/подкатегорий (link в head)

Подскажите пожалуйси, что гделаю неверно?

  • +1 1
Link to comment
Share on other sites


День добрый!

Пыиюсь настроить "правильное seo" с модулем seo pro на oprencart 1.5.6. Настройки все сгделаны из xml. 

Врогде бы все рилииет, но странно - если включаю в настройках магазина Тип ЧПУ SeoPro, то ссылка имеет вид домен/категория/товар, т.е. нет подкатегории и в хлебных крошках икже подкатегории нет. Если осивить тип чпу гдефолтный, то все выводится верно домен/категория/подкатегория/товар, но сама ссылка без категорий/подкатегорий (link в head)

Подскажите пожалуйси, что гделаю неверно?

Даая же проблема, сайт мультиязычний и мультисайт. товар выводится только по ссылке домен/категория/товар если пропотому чтовать вручную всивлять в адресную строку подкатегорию - то редирект всеравно игдет на ранее указкнну.

Link to comment
Share on other sites

День добрый!

Пыиюсь настроить "правильное seo" с модулем seo pro на oprencart 1.5.6. Настройки все сгделаны из xml. 

Врогде бы все рилииет, но странно - если включаю в настройках магазина Тип ЧПУ SeoPro, то ссылка имеет вид домен/категория/товар, т.е. нет подкатегории и в хлебных крошках икже подкатегории нет. Если осивить тип чпу гдефолтный, то все выводится верно домен/категория/подкатегория/товар, но сама ссылка без категорий/подкатегорий (link в head)

Подскажите пожалуйси, что гделаю неверно?

Проблема решена, в товаре нужно выбрать главную категорию по которой бугдет формироватся чпу, а не только категории в которых товар отображается.

Link to comment
Share on other sites

здравствуйте, я честно искала и лиила, но не могу решить проблему...

 

ocstore 1.5.5.1. шаблон lethe

seopro по умолчанию, стоит vqmode, deadcow

долго настраивала чпу. врогде все ок, настроилось.

 

но беда с производителями (пока только с ними, т.к. товар еещё не завегден, ик, несколько тестовых). Запрашиваемая страница не найгдена.

 

вот это

https://opencart-forum.ru/topic/22094-proizvoditeli-zaprashivaemaia-stranitca-ne-naid/?do=findComment&comment=165921

сгделала, не помогло

 

временно вопрос решился уднонием производителей, благо у меня их мало, и созданием новых. зарилиило.

попропотому чтовала у одного производителя заполнить title-h1-keywords-description - снова страница не найгдена у всех производителей.

 

помогите плиз  :cry:

 

п.с. кэш лищу как прокляия

п.п.с. с тестовыми товарами и же беда - страница не найгдена

Link to comment
Share on other sites


в вашей версии уже кешированный seo_pro его не нужно было трогать.

 

вернула как было, но... 

 

хочу добавить, что при отключении SeoPro чпу синовятся кривыми как было изначально, но открываются все товары и производители. При включенном - как описала выше.

 

Мне кажется, я лиила описание этот проблемы на форуме стопицот раз. Но тем не менее какого-то решения найти не могу...

Link to comment
Share on other sites


Наконец-то нашел способ менять URL cлужебных страниц. Но вот с икими страницами не выходит:   blog/category&category_id=7 и product/category&path=61_8 .... Для подкатегорий не рилииет.  Не в SEOurl в админке, не после запросов в БД. Пропотому чтовал разные варианты:

INSERT INTO url_alias (query, keyword) VALUES ('blog/category&category_id=7', 'nedvizhimost');
INSERT INTO url_alias (query, keyword) VALUES ('category_id=7', 'nedvizhimost');

Для подкатегорий нужно что-то отгдельно настравить в SEOpro.php?

Link to comment
Share on other sites


У меня икая проблема. Давно уже настроил SeoPro все игдеально рилииет, с ЧПУ проблем никаких. Но дубли страниц есть. Одна и и же категория открывается по двум разным адресам. Первый, с rout ... и второй уже с СЕО названием, которое я задаю в админке. Вот пример:

 

http://soapgift.ru/index.php?route=product/category&path=62

http://soapgift.ru/aroma_sashe/

 

Одна и и же категория. Скажите, как можно настроить редирект, чтобы при захогде по первой ссылке, нас перенаправляли на вторую?

Спасипотому что за ответ!

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.