Product Tag URL Upgrade

Posted: September 13, 2018 at 3:06 PM Quote #211891
I upgraded from 3.5 to 4.10 and it looks like at some point product tag URLS switched. They went from mystore.com/producttag/### to mystore.com/[slug] and are now in the URLRecord table.

It doesn't seem that there's a built-in redirect for this unless I'm missing it. Has anyone come up with an automated way to fix all of these /producttag/ urls which are now coming up as 404?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: September 14, 2018 at 2:32 AM Quote #211912
You're aboslutely right. We missed it. But you can easily add its support in BackwardCompatibility2XController file the same way it's done for other entities
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: September 14, 2018 at 1:27 PM Quote #211930
Thanks for that! I edited the file but routing is not working. I'm not sure what to look at next.


private readonly IProductTagService _productTagService;
....
public BackwardCompatibility2XController(IBlogService blogService,
            ICategoryService categoryService,
            IManufacturerService manufacturerService,
            INewsService newsService,
            IProductService productService,
            ITopicService topicService,
            IUrlRecordService urlRecordService,
            IVendorService vendorService,
            IProductTagService productTagService)
        {
            this._blogService = blogService;
            this._categoryService = categoryService;
            this._manufacturerService = manufacturerService;
            this._newsService = newsService;
            this._productService = productService;
            this._topicService = topicService;
            this._urlRecordService = urlRecordService;
            this._vendorService = vendorService;
            this._productTagService = productTagService;
        }



public virtual IActionResult RedirectProductTagById(int productTagId)
        {
            var productTag = _productTagService.GetProductTagById(productTagId);
            if (productTag == null)
                return RedirectToRoutePermanent("HomePage");

            return RedirectToRoutePermanent("ProductTag", new { SeName = _urlRecordService.GetSeName(productTag) });
        }


What am I missing? Do I need to reference this somewhere else in the application?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: September 15, 2018 at 1:28 PM Quote #211967
Hi.
Try to use the "ProductsByTag" route name. You can see the definition of such generic routes here.
This post/answer is useful
1
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: September 17, 2018 at 12:45 PM Quote #212033
I changed the code to

public virtual IActionResult RedirectProductTagById(int productTagId)
        {
            var productTag = _productTagService.GetProductTagById(productTagId);
            if (productTag == null)
                return RedirectToRoutePermanent("HomePage");

            return RedirectToRoutePermanent("ProductsByTag", new { SeName = _urlRecordService.GetSeName(productTag) });
        }


but it still isn't working. I apologize...I'm not very good with routing...
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: September 18, 2018 at 12:52 AM Quote #212048
You can see how we fixed it.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: September 18, 2018 at 10:42 AM Quote #212081
Thanks! The route provider piece was what I was missing.

For anyone coming at this in the future, you also need to add this to BackwardCompatibility2XRouteProvider.cs


//product tags
            routeBuilder.MapLocalizedRoute("", "producttag/{productTagId:min(0)}/{SeName?}",
                new { controller = "BackwardCompatibility2X", action = "RedirectProductTagById" });


Or, see the full fix in Romanov's link above.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2018
Learn more