Opencart duplicate URL keywords

前端 未结 5 1067
天涯浪人
天涯浪人 2020-12-20 01:36

How would I go about fixing the issue where two categories/products have the same URL in Opencart? Or if their is a module which already does this?

E.g: categories

5条回答
  •  青春惊慌失措
    2020-12-20 02:14

    if ($url[0] == 'category_id') {
        $categories[$i] = $this->model_catalog_category->getCategory($url[1]);
    
        if (!isset($this->request->get['path'])) {
            $this->request->get['path'] = $categories[$i]['category_id'];
        } else {
            foreach ($query->rows as $row) {
                $url = explode('=', $row['query']);
                $category_id = $url[1];
    
                $category = $this->model_catalog_category->getCategory($category_id);
    
                if ($category['parent_id'] == $categories[$i - 1]['category_id']) {
                    $this->request->get['path'] .= '_' . $category['category_id'];
                }
            }
        }
    }
    

    this will not work if its a 3 level category. I hope someone will have a better solution.

提交回复
热议问题