Inserting UrlRecord via sql - slug not visible in SEO tab, nor is page accessible.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
As I am creating my blog posts in my own VB.net program I am inserting the blog into the database from my program.

The blog post is created fine and the Insert for the urlRecord appears to work insofar as the record will appear in the table in the database, but the SEO tab does not display the se page name I inserted and the blog post is not clickable via the blog main/month page.

If I edit the blog post and then click the save button a new sepage name is created and the record I created myself will then be marked as Inactive.

Is there something else I need to execute once I have inserted a record into the URLRecord table to get the software to link it to the blog properly, so it is seen in the SEO tab and the blog post link is clickable?

Thanks for any help.
5 years ago
Hello,

What you are doing is right but I think you should check following things and make some modifications to your code.

# Check "GetSeName" method in "SeoExtensions.cs" file under Nop.Services project

# Allowed characters in SEO friendly name are "abcdefghijklmnopqrstuvwxyz1234567890 _-" and maximum length allowed is 200 chars as per defined in "ValidateSeName" method in same code file. Also, space is not allowed in SE name

# Take a look at this line "var seName = blogPost.ValidateSeName(model.SeName, model.Title, true);" line number 219 in "BlogController.cs" file under Admin -> Controllers in nopCommerce project

This will give you a clear idea of what mistake you are making. Hope this will help otherwise you can ask for more help here..
5 years ago
Thank you for the quick reply. I'm taking a look at those points now.
5 years ago
Optic Axis wrote:
Thank you for the quick reply. I'm taking a look at those points now.


No problem. Please vote up answer if it helps.

Thank you,
Atul
5 years ago
SEO names are cached, so you would need to clear the cache after manually inserting a UrlRecord row.
5 years ago
nopAdvance wrote:
Hello,

What you are doing is right but I think you should check following things and make some modifications to your code.

# Check "GetSeName" method in "SeoExtensions.cs" file under Nop.Services project

# Allowed characters in SEO friendly name are "abcdefghijklmnopqrstuvwxyz1234567890 _-" and maximum length allowed is 200 chars as per defined in "ValidateSeName" method in same code file. Also, space is not allowed in SE name

# Take a look at this line "var seName = blogPost.ValidateSeName(model.SeName, model.Title, true);" line number 219 in "BlogController.cs" file under Admin -> Controllers in nopCommerce project

This will give you a clear idea of what mistake you are making. Hope this will help otherwise you can ask for more help here..


Thank you. All my naming contained allowed characters and were well under the 200 character limit. I wish I could say I understood what was going on with the Caching when GetSeName runs but it was enough to show me I needed to somehow perform a cache update or requery.

timmit wrote:
SEO names are cached, so you would need to clear the cache after manually inserting a UrlRecord row.


This was what I was able to do to get the blogpost to show, so thank you for this answer.

One thing that I still don't quite understand is why (even after clearing the two tables of any related records) the blogpost sometimes showed up as a post in the 'Month' count, but other times it didn't. Because of the changes I was making to my code (such as setting language id to 0 or 1) I thought it was my changes that caused it, but it wasn't. It seems that a manually added blog post will sometimes be added to the month count (or even to show a month as having a single blog post, and sometimes the month name not appearing at all) and sometimes it wont, before clearing the cache manually.

Anyway I'm ok with this issue now, so thank you both for your help. This has enabled me to complete the part of my program which compiles a blog post from my own database and sends that and uploads images and adds them to the blog post all in one action, which saves me quite a bit of time from doing it manually.
5 years ago
Hello,

This sounds good. Anyway, if you still have any queries then I can help to review your code and see how it works exactly.

Thank you,
Atul
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.