summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2025-12-02 09:15:20 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2025-12-02 09:15:20 +0700
commitc03a690a935508c2c669a5e7ff6da3c50f42fb53 (patch)
tree730653686ca31f8bd8fa159347f6d8f341a18faf
parent781e5b025a412853afae7b8ed4d9a7ff7aff6655 (diff)
<Miqdad> change url mod gen
-rw-r--r--indoteknik_custom/models/find_page.py31
1 files changed, 12 insertions, 19 deletions
diff --git a/indoteknik_custom/models/find_page.py b/indoteknik_custom/models/find_page.py
index 461e647d..5e530c64 100644
--- a/indoteknik_custom/models/find_page.py
+++ b/indoteknik_custom/models/find_page.py
@@ -130,31 +130,24 @@ class FindPage(models.Model):
find_page = self.env['web.find.page'].create(param)
_logger.info('Created Web Find Page %s' % find_page.id)
- def _generate_mod_url(self, category, brand, keyword):
- # generate_url = 'https://indoteknik.com/shop/find/category-brand' example
+ def _generate_mod_url(self, category, brand, keyword=None):
cleaned_category = re.sub(r'[^\w\s]', '', category.name)
cleaned_brand = re.sub(r'[^\w\s]', '', brand.x_name)
- cleaned_combined = cleaned_category+' '+cleaned_brand
- cleaned_combined = cleaned_combined.replace(' ', '-')
- cleaned_combined = cleaned_combined.replace('--', '-')
- if self.keywords:
- url = 'https://indoteknik.com/shop/find/key='+keyword
+ cleaned_combined = f"{cleaned_category} {cleaned_brand}"
+ cleaned_combined = re.sub(r'\s+', '-', cleaned_combined.strip())
+
+ if keyword:
+ slugified_keyword = re.sub(r'\s+', '-', keyword.strip().lower())
+ url = f"https://indoteknik.com/shop/find/key={slugified_keyword}"
else:
- url = 'https://indoteknik.com/shop/find/'+cleaned_combined
- url = url.lower()
+ url = f"https://indoteknik.com/shop/find/{cleaned_combined.lower()}"
+
result = {
'url': url,
'category_id': category.id,
'brand_id': brand.id
}
- if self.keywords:
- result['keywords_s'] = keyword
- # print(url)
- # param = {
- # 'brand_id': brand.id,
- # 'category_id': category.id,
- # 'url':''
- # }
- # self.env['web.find.page'].create()
- # print(1)
+ if keyword:
+ result['keyword_s'] = keyword
+
return result