Категории услуг и удаление latest из блога
This commit is contained in:
@@ -67,7 +67,7 @@ class SeoPro {
|
||||
|
||||
if(!empty($url[0])) {
|
||||
|
||||
if(!in_array($url[0], ['category_id', 'product_id', 'manufacturer_id', 'information_id', 'article_id', 'blog_category_id', 'service_id'])) {
|
||||
if(!in_array($url[0], ['category_id', 'product_id', 'manufacturer_id', 'information_id', 'article_id', 'blog_category_id', 'service_category_id', 'service_id'])) {
|
||||
return $parts;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,12 @@ class SeoPro {
|
||||
} else {
|
||||
$this->request->get['blog_category_id'] .= '_' . $url[1];
|
||||
}
|
||||
} elseif ($url[0] == 'service_category_id') {
|
||||
if (!isset($this->request->get['service_category_id'])) {
|
||||
$this->request->get['service_category_id'] = $url[1];
|
||||
} else {
|
||||
$this->request->get['service_category_id'] .= '_' . $url[1];
|
||||
}
|
||||
} elseif (count($url) > 1) {
|
||||
$this->request->get[$url[0]] = $url[1];
|
||||
}
|
||||
@@ -128,7 +134,14 @@ class SeoPro {
|
||||
|
||||
//services
|
||||
if (isset($this->request->get['service_id'])) {
|
||||
if(isset($this->request->get['service_category_id'])) {
|
||||
unset($this->request->get['service_category_id']);
|
||||
};
|
||||
$service_category_path = $this->getServicePathByService($this->request->get['service_id']);
|
||||
if ($service_category_path) $this->request->get['service_category_id'] = $service_category_path;
|
||||
$this->request->get['route'] = 'service/service/info';
|
||||
} elseif (isset($this->request->get['service_category_id'])) {
|
||||
$this->request->get['route'] = 'service/category';
|
||||
}
|
||||
//end services
|
||||
|
||||
@@ -225,14 +238,32 @@ class SeoPro {
|
||||
case 'service/service/info':
|
||||
if (isset($data['service_id'])) {
|
||||
$route = 'service/service/info';
|
||||
$service_path = '';
|
||||
$service_id = $data['service_id'];
|
||||
|
||||
if (isset($data['service_category_id']) || $this->config->get('config_seo_url_include_path')) {
|
||||
$service_path = $this->getServicePathByService($service_id);
|
||||
}
|
||||
|
||||
unset($data);
|
||||
$data['route'] = $route;
|
||||
|
||||
if ($service_path && $this->config->get('config_seo_url_include_path')) {
|
||||
$data['service_category_id'] = $service_path;
|
||||
}
|
||||
|
||||
$data['service_id'] = $service_id;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'service/category':
|
||||
if (isset($data['service_category_id'])) {
|
||||
$service_category = explode('_', $data['service_category_id']);
|
||||
$service_category = end($service_category);
|
||||
$data['service_category_id'] = $this->getServicePathByCategory($service_category);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'product/category':
|
||||
if (isset($data['path'])) {
|
||||
$category = explode('_', $data['path']);
|
||||
@@ -314,6 +345,13 @@ class SeoPro {
|
||||
$postfix = true;
|
||||
unset($data[$key]);
|
||||
break;
|
||||
case 'service_category_id':
|
||||
$service_categories = explode('_', $value);
|
||||
foreach ($service_categories as $service_category_id) {
|
||||
$queries[] = 'service_category_id=' . (int)$service_category_id;
|
||||
}
|
||||
unset($data[$key]);
|
||||
break;
|
||||
//end services
|
||||
case 'path':
|
||||
$categories = explode('_', $value);
|
||||
@@ -695,6 +733,52 @@ class SeoPro {
|
||||
return $blog_path[$blog_category_id];
|
||||
}
|
||||
|
||||
private function getServicePathByService($service_id) {
|
||||
|
||||
if ($service_id < 1)
|
||||
return false;
|
||||
|
||||
$query = $this->db->query("SELECT service_category_id FROM " . DB_PREFIX . "service_to_category WHERE service_id = '" . (int)$service_id . "' LIMIT 1");
|
||||
|
||||
return $this->getServicePathByCategory($query->num_rows ? (int)$query->row['service_category_id'] : 0);
|
||||
}
|
||||
|
||||
private function getServicePathByCategory($service_category_id) {
|
||||
$service_category_id = (int)$service_category_id;
|
||||
if ($service_category_id < 1)
|
||||
return false;
|
||||
|
||||
static $service_path = [];
|
||||
$cache = 'seopro.service_category.seopath';
|
||||
|
||||
if (!is_array($service_path)) {
|
||||
if ($this->config->get('config_seo_url_cache'))
|
||||
$service_path = $this->cache->get($cache);
|
||||
if (!is_array($service_path))
|
||||
$service_path = [];
|
||||
}
|
||||
|
||||
if (!isset($service_path[$service_category_id])) {
|
||||
$max_level = 10;
|
||||
$sql = "SELECT CONCAT_WS('_'";
|
||||
for ($i = $max_level-1; $i >= 0; --$i) {
|
||||
$sql .= ",t$i.service_category_id";
|
||||
}
|
||||
$sql .= ") AS path FROM " . DB_PREFIX . "service_category t0";
|
||||
for ($i = 1; $i < $max_level; ++$i) {
|
||||
$sql .= " LEFT JOIN " . DB_PREFIX . "service_category t$i ON (t$i.service_category_id = t" . ($i-1) . ".parent_id)";
|
||||
}
|
||||
$sql .= " WHERE t0.service_category_id = '" . $service_category_id . "'";
|
||||
$query = $this->db->query($sql);
|
||||
$service_path[$service_category_id] = $query->num_rows ? $query->row['path'] : false;
|
||||
|
||||
if ($this->config->get('config_seo_url_cache'))
|
||||
$this->cache->set($cache, $service_path);
|
||||
}
|
||||
|
||||
return $service_path[$service_category_id];
|
||||
}
|
||||
|
||||
private function strpos_offset($needle, $haystack, $occurrence) {
|
||||
// explode the haystack
|
||||
$arr = explode($needle, $haystack);
|
||||
@@ -728,4 +812,4 @@ class SeoPro {
|
||||
$this->cache->set('seopro.product_categories', $this->product_categories);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user