Before this commit, when an user would visit a subcategory in the ecommerce, he would see a slugified URL, containing all the category hierarchy, which is good for SEO purpose. For example, if `Wheel` is a child of `Car` which is a child of `Vehicule`, then the URL would be `/shop/category/vehicule-car-wheel-3`. But on the sitemap, the parents would not be prefixed to the URL, thus the sitemap would simply show `<loc>/shop/category/wheel-3</loc>`. This commit ensure the category parents are added to the final URL of the sitemap, as in the ecommerce. task-1889972 closes odoo/odoo#34073 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
26 lines
838 B
Python
26 lines
838 B
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import HttpCase, tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestSitemap(HttpCase):
|
|
|
|
def setUp(self):
|
|
super(TestSitemap, self).setUp()
|
|
|
|
self.cats = self.env['product.public.category'].create([{
|
|
'name': 'Level 0',
|
|
}, {
|
|
'name': 'Level 1',
|
|
}, {
|
|
'name': 'Level 2',
|
|
}])
|
|
self.cats[2].parent_id = self.cats[1].id
|
|
self.cats[1].parent_id = self.cats[0].id
|
|
|
|
def test_01_shop_route_sitemap(self):
|
|
resp = self.url_open('/sitemap.xml')
|
|
level2_url = '/shop/category/level-0-level-1-level-2-%s' % self.cats[2].id
|
|
self.assertTrue(level2_url in resp.text, "Category entry in sitemap should be prefixed by its parent hierarchy.")
|