Jump to content

Recommended Posts

Добрый день, хочу сделать, чтобы производители отображались в виде sitename.ru/brands/brand_name

Для этого в seo_pro.php поменял код

Тут

	$queries = array();
		$id_manufacturer = false;//new
		if(!in_array($route, array('product/search'))) {
			foreach($data as $key => $value) {
				switch($key) {
					case 'product_id':
					//case 'manufacturer_id':
					//manufacturers brands
					case 'manufacturer_id':
					$queries[] = $key . '=' . $value;
					unset($data[$key]);
					$postfix = 1;
					$id_manufacturer = true;
					break;
	//manufacturers brands

 И еще здесь

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

		if ($id_manufacturer) {
//if (in_array('davinci72/brands', explode('/', $_SERVER['REQUEST_URI']))) {
		//	if(strpos($_SERVER['REQUEST_URI'], '/davinci72.ru/brands/') == true)	{
				$seo_url .= '/brands/' . rawurlencode($aliases[$query]);
		//}

		//}
	}
	 else
		{
		$seo_url .= '/' . rawurlencode($aliases[$query]);
		}
		}
	}
// /Manufacturer brands/

Но на странице товаров начинает дублироваться слово brand, в самих производителях все нормально отображается, как это можно исправить? Пытался условие сделать, чтобы слово бренд в URL добавлялось только если страница с брендами, но что-то не помогло.

Безымянный.png

Edited by Timur3294237423428934

Share this post


Link to post
Share on other sites

А просто добавить вот так пробовали?

image.png.d124a6e3238b75c0a5011123c8538960.png

 

image.png.16f0d8c7808269b58445207c578208ee.png

Share this post


Link to post
Share on other sites
29 минут назад, Timur3294237423428934 сказал:

@Eldaeron Ко всем страницам c товарами этот url стал добавляться 

Перед кодом:

if(!in_array($route, array('product/search'))) {

Вставить:

$brand = false;

Удалить

case 'manufacturer_id':

Выше 

case 'product_id':

Вставить:

case 'manufacturer_id':
						$brand = true;
						$queries[] = $key . '=' . $value;
						unset($data[$key]);
						$postfix = 1;
						break;

После:

$seo_url = trim($seo_url, '/');

Вставить:

if ($brand) {
			$seo_url = "brands/" . $seo_url;
		}

 

В картинках:

 

image.png.1114d0dce402ec76b220e194d29503c7.png

image.png.d4ad050c17954d79535cf766b9533f04.png

 

Попробуйте так.

Share this post


Link to post
Share on other sites
break;

добавьте после вставленной строки

Share this post


Link to post
Share on other sites

Почему-то при клике на все страницы выдает только список производителей

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

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

				case 'download_id':

				case 'search':
				case 'sub_category':
				case 'description':

				// Compatibility with Shopencart News/Blog:
				case 'news_id':
				case 'author':
				case 'ncat':

				// Compatibility with VDF News (villagedefrance)
				case 'news_id':
				case 'posts_id':

				// Compatibility with unknown Blog:
				case 'blog_id':
				case 'blog_category_id':
				case 'blogpath':

					$queries[] = $key . '=' . $value;
					unset($data[$key]);
					$postfix = 1;
					break;

				case 'page':
					if($value == 1) {
						unset($data[$key]);
					} else {
						$queries[] = $key . '=' . $value;
					}
					break;

				case 'path':
					// ATTN: user can set any path: path=2_4_1_2_3
					$category_path = explode('_', $value);

					// find real category path:
					$category_id = end($category_path);
					$categories = $this->getPathByCategory($category_id);

					// save all categories queries to find later their aliases
					$categories = explode('_', $categories);
					foreach ($categories as $category) {
						$queries[] = 'category_id=' . $category;
					}
					unset($data[$key]);
					break;

				default:
					break;
			}
		}

Эта структура seo_pro отличается от стандартной, как быть?


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

		$seo_url = $code . trim($seo_url, '/');

		if ($brand) {
					$seo_url = "brands/" . $seo_url;
				}

 

Edited by Timur3294237423428934

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.