Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Nikolay_23

Newbie
  
  • Posts

    19
  • Joined

  • Last visited

About Nikolay_23

  • Birthday 07/12/1991

Information

  • Gender
    Мужчина
  • City:
    Украина
    Одесса

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Nikolay_23's Achievements

Apprentice

Apprentice (3/14)

  • One Year In
  • Collaborator
  • First Post
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. Не могу понять куда копать... Версия ocStore 3.0.3.7 В настрайках включен seo pro .htaccess перименован.. Но сайт работает как с чпу так и без Оно же должно с не чепу перекидывать на чпу... Куда копать?
  2. Добрый день! Есть ссылка на товар site.com/catalog/catalog/product.html На сайте используется штатный seo_url.php + seo_url_mod.php Нужно что карточка товара работала с парметрами типа ?=key или ?utm Потому что сейчас срабатывает 301 редирект.. код прилагаю.. Нужна ваша помощь... Товар должен открываться по такой ссылке site.com/catalog/catalog/product.html?key=1234 <?php class ControllerStartupSeoUrlMod extends Controller { private $cat_tree = [ ]; private $keywords = [ ]; private $queries = [ ]; private $product_categories = [ ]; public function __construct($registry) { parent::__construct($registry); if (isset($this->request->get['_route_'])) { $this->request->get['_route_'] = preg_replace('/' . '.html' . '$/', '', (string) $this->request->get['_route_']); } $this->cache = $registry->get('cache'); $this->cat_tree = $this->cache->get('seourl.cat_tree'); if (empty($this->cat_tree)) { $this->cat_tree = [ ]; $query = $this->db->query("SELECT category_id, parent_id FROM " . DB_PREFIX . "category ORDER BY parent_id"); $categories = [ ]; foreach ($query->rows as $category) { $categories[$category['category_id']]['parent_id'] = $category['parent_id']; }; foreach ($categories as $category_id => $category) { $path = $this->getPath($categories, $category_id); $this->cat_tree[$category_id]['path'] = $path; }; } $this->keywords = $this->cache->get('seourl.keywords'); $this->queries = $this->cache->get('seourl.queries'); if (empty($this->keywords) || empty($this->queries)) { $sql = "SELECT LCASE(keyword) as keyword, query, store_id, language_id FROM " . DB_PREFIX . "seo_url"; $query = $this->db->query($sql); if ($query->num_rows) { foreach ($query->rows as $row) { $this->keywords[$row['query']][$row['store_id']][$row['language_id']] = $row['keyword']; $this->queries[$row['keyword']][$row['store_id']][$row['language_id']] = $row['query']; } } } } public function index() { $this->url->addRewrite($this); if (isset($this->request->get['_route_'])) { $parts = explode('/', $this->request->get['_route_']); if (utf8_strlen(end($parts)) == 0) { array_pop($parts); } $store_id = (int) $this->config->get('config_store_id'); $language_id = (int) $this->config->get('config_language_id'); foreach ($parts as $part) { $query = [ ]; $keyword = utf8_strtolower($part); if (isset($this->queries[$keyword][$store_id][$language_id])) { $query = $this->queries[$keyword][$store_id][$language_id]; } if ($query) { $url = explode('=', $query); if (!in_array($url[0], [ 'category_id', 'product_id', 'manufacturer_id', 'news_id', 'news2_id', 'news3_id', 'information_id'])) { $this->request->get['route'] = $query; } elseif ($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'; break; } } if (!isset($this->request->get['route'])) { if (isset($this->request->get['product_id'])) { $path = $this->getCategoryByProduct($this->request->get['product_id']); if ($path) { $this->request->get['path'] = $path; } $this->request->get['route'] = 'product/product'; } 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->request->get['news_id'])) { $this->request->get['route'] = 'information/news/info'; } elseif (isset($this->request->get['news2_id'])) { $this->request->get['route'] = 'information/news2/info'; } elseif (isset($this->request->get['news3_id'])) { $this->request->get['route'] = 'information/news3/info'; } } if (empty($this->request->get['route'])) { $this->request->get['route'] = 'common/home'; } if (isset($this->request->get['route'])) { $break_routes = [ 'error/not_found', 'extension/feed/google_sitemap', 'extension/feed/google_base', 'extension/feed/sitemap_pro', 'extension/feed/yandex_feed' ]; if (in_array($this->request->get['route'], $break_routes)) return; } if (isset($this->request->server['HTTP_X_REQUESTED_WITH']) && strtolower($this->request->server['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { return; } if ($_SERVER['HTTPS'] == true) { $host = substr($this->config->get('config_ssl'), 0, $this->strpos_offset('/', $this->config->get('config_ssl'), 3) + 1); } else { $host = substr($this->config->get('config_url'), 0, $this->strpos_offset('/', $this->config->get('config_url'), 3) + 1); } $exclude = urldecode(http_build_query(array_diff_key($this->request->get, array_flip(array( '_route_', 'route'))))); $url_validate = str_replace('&amp;', '&', $host . ltrim($this->request->server['REQUEST_URI'], '/')); $seo_validate = str_replace('&amp;', '&', $this->url->link($this->request->get['route'], $exclude, $_SERVER['HTTPS'])); if (rawurldecode($url_validate) != rawurldecode($seo_validate)) { $this->response->redirect($seo_validate, 301); } } private function strpos_offset($needle, $haystack, $occurrence) { $arr = explode($needle, $haystack); 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 getPath($categories, $category_id, $current_path = [ ]) { if (!$current_path) $current_path = [ (int) $category_id]; $path = $current_path; $parent_id = 0; if (isset($categories[$category_id]['parent_id'])) { $parent_id = (int) $categories[$category_id]['parent_id']; } if ($parent_id > 0) { $new_path = array_merge([ $parent_id], $current_path); $path = $this->getPath($categories, $parent_id, $new_path); } return $path; } public function rewrite($link) { $url_info = parse_url(str_replace('&amp;', '&', $link)); parse_str($url_info['query'], $data); $ishome = 0; $url = ''; switch ($data['route']) { case 'product/product': if (isset($data['product_id'])) { $route = 'product/product'; $product_id = $data['product_id']; unset($data); $data['route'] = $route; $path = $this->getCategoryByProduct($product_id); if ($path) { $data['path'] = $path; } $data['product_id'] = $product_id; } break; case 'product/category': if (isset($data['path'])) { $category = explode('_', $data['path']); $category = end($category); $data['path'] = $this->getPathByCategory($category); } break; case 'common/home': $ishome = 1; break; case 'information/information/agree': return $link; break; case 'information/information/info': return $link; break; default: break; } if (isset($data['news_id'])) { $url = '/news'; } elseif (isset($data['news2_id'])) { $url = '/articles'; } elseif (isset($data['news3_id'])) { $url = '/services'; } $route = ''; if (isset($data['route'])) { $route = $data['route']; unset($data['route']); } $queries = [ ]; foreach ($data as $key => $value) { switch ($key) { case 'product_id': case 'manufacturer_id': case 'category_id': case 'information_id': case 'news_id': case 'news2_id': case 'news3_id': $queries[] = $key . '=' . (int) $value; unset($data[$key]); break; case 'path': $categories = explode('_', $value); foreach ($categories as $category_id) { $queries[] = 'category_id=' . (int) $category_id; } unset($data[$key]); break; default: break; } } if (empty($queries) && $route) { $keyword = $this->getKeywordByQuery($route); if ($keyword !== null) { if ($keyword !== '') { $url = '/' . rawurlencode($keyword); } } $data['route'] = $route; } else { $rows = [ ]; foreach ($queries as $query) { $keyword = $this->getKeywordByQuery($query); if ($keyword) { $rows[] = $keyword; } } if (!empty($rows) && (count($rows) == count($queries))) { foreach ($rows as $row) { $url .= '/' . rawurlencode($row); } } } if ($url) { $url .= '.html'; unset($data['route']); $query = ''; if ($data) { foreach ($data as $key => $value) { $query .= '&' . rawurlencode((string) $key) . '=' . rawurlencode((is_array($value) ? http_build_query($value) : (string) $value)); } if ($query) { $query = '?' . str_replace('&', '&amp;', trim($query, '&')); } } return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query; } elseif ($ishome) { return str_replace('index.php?route=common/home', '', $link); } else { return $link; } } private function getCategoryByProduct($product_id) { if (!$product_id) { return false; } $this->product_categories = $this->cache->get('seourl.product_categories'); if (isset($this->product_categories[$product_id])) { return $this->product_categories[$product_id]; } $query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int) $product_id . "' ORDER BY main_category DESC LIMIT 1"); $category_id = $this->getPathByCategory($query->num_rows ? (int) $query->row['category_id'] : 0); $this->product_categories[$product_id] = $category_id; return $category_id; } private function getPathByCategory($category_id) { $path = ''; if (!$category_id && !isset($this->cat_tree[$category_id])) return false; if (!empty($this->cat_tree[$category_id]['path']) && is_array($this->cat_tree[$category_id]['path'])) { $path = implode('_', $this->cat_tree[$category_id]['path']); } return $path; } private function getKeywordByQuery($query) { $keyword = null; $store_id = (int) $this->config->get('config_store_id'); $language_id = $this->config->get('config_language_id'); if (isset($this->keywords[$query][$store_id][$language_id])) { $keyword = $this->keywords[$query][$store_id][$language_id]; } return $keyword; } public function __destruct() { $this->cache->set('seourl.keywords', $this->keywords); $this->cache->set('seourl.queries', $this->queries); $this->cache->set('seourl.cat_tree', $this->cat_tree); $this->cache->set('seourl.product_categories', $this->product_categories); } }
  3. Можете на примере показать.. https://regex101.com/r/fBU5uC/1 пробовал что то не получается ничего..(
  4. Мне нужно только то что идет после 4 запятой http://joxi.ru/LmG4ZGQcB80vZ2 А так как вы предлагаете оно выделяет всю строку http://joxi.ru/J2byvYETqJ6lBm
  5. Не срабатывает.. ве выделяет https://regex101.com/r/YuwThT/1
  6. Я как раз там и тестирую.. спасибо) Но я не могу составить верный код.. как я это понимаю.. мы пропускаем все что идет до 4 запятой.. далее берем все что идет после 4 запятой и до конца строки или до ; и через нодапд я это все удаляю... http://joxi.ru/Y2L4nBLcxX5Mz2 Сможет кто то подсказать само регулярной выражение? или статью где есть пример с отсчетом нужного элемента..
  7. Это не походит.. потому что я использую регулярку через нодпад.. это я в ручную хочу сделать..
  8. Нет.. иногда может быть больше.. Это для таблиц в бд
  9. Есть вот такая строка ('6', '2', 'total', 'Ümumi', '11.0000', '9', '11.00 AZN'); Мне нужно найти все что идет после 4 запятой и до ; т.е мне нужно выделить вот эту часть включая последнюю запятую.. , '11.0000', '9', '11.00 AZN'); Везде пишут как найти любой символ, цифру группу и т.д... но ни где не нашел где можно выбрать то что мне нужно.. Помогите кто знает...
  10. Тема закрыта.. разобрался сам.. всем спасбо)
  11. Всем примет.. нужна помощь. В модуле Import/Export http://joxi.ru/a2XDMEyUQz5qn2 нужно отключить проверку уникальности для урл.. В админке я уже отключил.. и теперь могу для одного товара создавать один урл.. но для разных языков урл будет разделятся префиксом /ua/ /en/ /ru/ Чеерз админку могу а через модуль не получается найти и отключить.. может кто подсказать.. Модуль Import/Export самый обычный скачанный с сайта опенкарт ком
  12. Спасибо! Еще попробую конечно.. Если не получится тогда буду искать другой модуль.. Всем спасибо!
×
×
  • 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.