From d3a415c67904b97ab2ec14de9c9108de724a02ae Mon Sep 17 00:00:00 2001 From: abantecart Date: Tue, 8 Apr 2014 23:07:45 -0400 Subject: [PATCH] Fix for breadcrumb in SEO URL mode. --- .../controller/pages/product/category.php | 5 ++++- .../storefront/model/catalog/category.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/public_html/storefront/controller/pages/product/category.php b/public_html/storefront/controller/pages/product/category.php index 37195813e1..d0fb2e6202 100755 --- a/public_html/storefront/controller/pages/product/category.php +++ b/public_html/storefront/controller/pages/product/category.php @@ -48,7 +48,10 @@ public function main() { $path = ''; $parts = explode('_', $this->request->get['path']); - + if ( count($parts) == 1 ) { + //see if this is a category ID to sub category, need to build full path + $parts = explode('_', $this->model_catalog_category->buildPath($this->request->get['path'])); + } foreach ($parts as $path_id) { $category_info = $this->model_catalog_category->getCategory($path_id); diff --git a/public_html/storefront/model/catalog/category.php b/public_html/storefront/model/catalog/category.php index bb36b15daf..35f6e00342 100755 --- a/public_html/storefront/model/catalog/category.php +++ b/public_html/storefront/model/catalog/category.php @@ -199,4 +199,21 @@ public function getCategoriesBrands($categories=array()){ return $query->rows; } + /** + * @param int $category_id + * @return string\ + */ + public function buildPath($category_id) { + $query = $this->db->query("SELECT c.category_id, c.parent_id + FROM " . DB_PREFIX . "categories c + WHERE c.category_id = '" . (int)$category_id . "' + ORDER BY c.sort_order"); + + $category_info = $query->row; + if ($category_info['parent_id']) { + return $this->buildPath($category_info['parent_id']) . "_" . $category_info['category_id']; + } else { + return $category_info['category_id']; + } + } }