Resolved - Deleted URLRecords now links don't work

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 Jahre weitere
I deleted all records in the urlrecords table as I was getting errors with % signs. I hoped the absence of a slug record would mean the URL used would be the same as in 2.6

Now none of my links work (categories or products).

Is there a fix?
Is there a proc to re-populate these records?
Is there a way to revert to URLs with ID's

Thanks

Darren
11 Jahre weitere
If I manually save a product it automatically re-populates the URLRecord "slug" record. Surely there is an easier way to do this than for me to go through 15,000 records manually saving each one.

Any help?

Darren
11 Jahre weitere
GetSeName method should NEVER return an empty string as it is always required, otherwise the link will not work. I have changed the method to include


if (result == "")
            {
               result = ValidateSeName(entity, "", "", true);
                urlRecordService.SaveSlug(entity, result, 0);
            }


This way, if there is no SeName the entityId will be used instead.

The full method is now


        public static string GetSeName<T>(this T entity, int languageId, bool returnDefaultValue = true,
            bool ensureTwoPublishedLanguages = true)
            where T : BaseEntity, ISlugSupported
        {
            if (entity == null)
                throw new ArgumentNullException("entity");

            string result = string.Empty;
            string entityName = typeof(T).Name;

            var urlRecordService = EngineContext.Current.Resolve<IUrlRecordService>();
            if (languageId > 0)
            {
                //ensure that we have at least two published languages
                bool loadLocalizedValue = true;
                if (ensureTwoPublishedLanguages)
                {
                    var lService = EngineContext.Current.Resolve<ILanguageService>();
                    var totalPublishedLanguages = lService.GetAllLanguages(false).Count;
                    loadLocalizedValue = totalPublishedLanguages >= 2;
                }
                //localized value
                if (loadLocalizedValue)
                {
                    result = urlRecordService.FindSlug(entity.Id, entityName, languageId);
                }
            }
            //set default value if required
            if (String.IsNullOrEmpty(result) && returnDefaultValue)
            {
                result = urlRecordService.FindSlug(entity.Id, entityName, 0);
            }

            if (result == "")
            {
               result = ValidateSeName(entity, "", "", true);
                urlRecordService.SaveSlug(entity, result, 0);
            }
            result = HttpUtility.UrlEncode(result);
            return result;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.