From 861a0d030ae32f6a7b379884e1107f4e44ab22fd Mon Sep 17 00:00:00 2001 From: Mohammad Tomaraei Date: Wed, 19 Feb 2020 19:10:26 +0100 Subject: [PATCH] added trimming to url paths --- src/catalog/controller/vsbridge/categories.php | 6 +++--- src/catalog/controller/vsbridge/products.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/catalog/controller/vsbridge/categories.php b/src/catalog/controller/vsbridge/categories.php index 183a234..8be6fd7 100644 --- a/src/catalog/controller/vsbridge/categories.php +++ b/src/catalog/controller/vsbridge/categories.php @@ -130,14 +130,14 @@ public function mapFields(array &$elements, $current_level = 0, $id_path = array $element['slug'] = $name_slug.'-'.$element['id']; // Change if you use a custom SEO extension - $element['url_key'] = $element['slug']; - $element['url_path'] = implode('/', array_merge($name_path, array($name_slug))).'-'.$element['id']; + $element['url_key'] = trim($element['slug']); + $element['url_path'] = trim(implode('/', array_merge($name_path, array($name_slug))).'-'.$element['id']); // Check for SEO URls via the OpenCart extension [SEO BackPack 2.9.1] $seo_url_alias = $this->model_vsbridge_api->getSeoUrlAlias('category', $element['id'], $this->language_id); if(!empty($seo_url_alias['keyword'])){ - $element['url_path'] = $seo_url_alias['keyword']; + $element['url_path'] = trim($seo_url_alias['keyword']); } $element['level'] = $current_level + 1; diff --git a/src/catalog/controller/vsbridge/products.php b/src/catalog/controller/vsbridge/products.php index 80e5c67..471c688 100644 --- a/src/catalog/controller/vsbridge/products.php +++ b/src/catalog/controller/vsbridge/products.php @@ -311,16 +311,16 @@ public function populateProducts($input){ $oc_url_alias = $this->model_vsbridge_api->getUrlAlias('product', $product['product_id']); if(!empty($oc_url_alias['keyword'])){ - $product_array['slug'] = $oc_url_alias['keyword']; - $product_array['url_path'] = $oc_url_alias['keyword']; + $product_array['slug'] = trim($oc_url_alias['keyword']); + $product_array['url_path'] = trim($oc_url_alias['keyword']); } // Check for SEO URls via the OpenCart extension [SEO BackPack 2.9.1] $seo_url_alias = $this->model_vsbridge_api->getSeoUrlAlias('product', $product['product_id'], $this->language_id); if(!empty($seo_url_alias['keyword'])){ - $product_array['slug'] = $seo_url_alias['keyword']; - $product_array['url_path'] = $seo_url_alias['keyword']; + $product_array['slug'] = trim($seo_url_alias['keyword']); + $product_array['url_path'] = trim($seo_url_alias['keyword']); } // Related products