November Happy Hour will be moved to Thursday December 5th.

Name in URL property clash in multi-language scenario

Vote:
 

Hi

Per above Epi documentation snippet, it says Name in URL must be unique within same parent category. From the example URL provided :

example.com/en/catalog/category/subcategory/product

Does it mean that if I have 2 languages on the site (en and sv), then the Name in URL part of "subcategory" needs to be unique for both en and sv language paths?

Issue : I'm trying to save a category in "sv" language after saving it in "en" and I get this error :

"Name in URL" with value "Candles-Shop-by-Vessel-Shop-All-Vessels" is already in use by Shop All Vessels (1073742273__CatalogContent).

This only happens when doing this programmatically. When doing this via the CMS Admin UI, it works fine.

What I've noticed so far in th code, is that it only looks at the URL Segment : category/subcategory/product, and not the full URL, to know the language branch. How can I make the code look at the full URL?

This is the code that throws above exception :

categoryLink = contentRepository.Save(newCategory, SaveAction.Publish | SaveAction.ForceNewVersion, AccessLevel.NoAccess);

Please advice.

Regards

Ritu

#204359
May 28, 2019 21:52
Vote:
 

What is the entire source code for saving sv language? Something might be wrong there

#204362
May 28, 2019 22:51
Vote:
 

Hi Quan

I found the issue.. I later noticed my code wasn't cloning existing category for language branch, and instead trying to create new category with same URLSegment, hence throwing the exception. Now i'm no longer getting this exception, and per the code the language branch seems to be getting saved correctly. However, i'm not seeing this on the interface. Even when the default branch is published, my language branch isn't. So i'm still working through this. Any inpt would be appreciated.

As for code, i'm essentialy passing new CultureInfo(language), when I Get any content, so I get correct language version. This has worked beautifully for products and variants, but not really for categories.

newCategory = contentRepository.Get<NodeContent>(categoryLink, new CultureInfo(language)).CreateWritableClone() as NodeContent;

#204363
May 28, 2019 22:58
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.