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

Хлебные крошки при перехогде в товар из главной


Recommended Posts

Кто то решал рилиту хлебных крошек без включения seopro ?
при перехогде в товар из главной в хлебных крошках отсутствует категория

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

Link to comment
Share on other sites


В обещём нашел решение для oc 2.3
 

catalog/controller/product/product.php

перед 
public function index() {

всивляем

protected function getPath($parent_id, $current_path = '') {
				$category_info = $this->model_catalog_category->getCategory($parent_id);          
				if ($category_info) {
					if (!$current_path) {
						$new_path = $category_info['category_id'];
					} else {
						$new_path = $category_info['category_id'] . '_' . $current_path;
					}			  
					$path = $this->getPath($category_info['parent_id'], $new_path);			  
					if ($path) {
						return $path;
					} else {
						return $new_path;
					}
				}
			}


после

if ($product_info) {

всивляем

if(!isset($category_info)) {
				$categories = $this->model_catalog_product->getCategories($this->request->get['product_id']);
				if($categories) {				
					foreach($categories as $category){			  
						$path = $this->getPath($category['category_id']);
						$category_info = $this->model_catalog_category->getCategory($category['category_id']);
						if($path){
							$cat_path = $path;
						}else{
							$cat_path = $category_info['category_id'];
						}				  
						if($category_info) {
							$path = '';
							$cat_path = explode('_', $cat_path);
							foreach ( $cat_path as $path_id) {
							  if (!$path) {
								$path = $path_id;
							  } else {
								$path .= '_' . $path_id;
							  }
								  
							  $category_info = $this->model_catalog_category->getCategory($path_id);
							  
							  if ($category_info) {
								  $data['breadcrumbs'][] = array(
								  'text'      => $category_info['name'],
								  'href'      => $this->url->link('product/category', '&path=' . $path),
								  'separator' => $this->language->get('text_separator')
								  );
								}
							}
						break;
						}			  
					}
				}
			}

 

Link to comment
Share on other sites


  • 5 weeks later...
В 15.07.2020 в 11:27, emain сказал:

В обещём нашел решение для oc 2.3

 

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

@emain eсли код Ваш, помогите разобраться, как это поправить, или погделитесь координаими автора пожалуйси.

 

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

"SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . $product_id . "' ORDER BY main_category DESC LIMIT 1"

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.