Catalog localisation

Vote:
 

Hi all!

I am trying to create a catalog from code. Catalog with the same name should be created for two markets with different default languages and currencies.

     var root = _referenceConverter.GetRootLink();

            var catalog = _contentRepository.GetDefault(root);

            catalog.Name = name;

            catalog.DefaultLanguage = market.DefaultLanguage.Name;

            catalog.DefaultCurrency = market.DefaultCurrency;

            catalog.Language = market.DefaultLanguage;

            catalog.WeightBase = "Kilograms";

_contentRepository.Save(catalog, SaveAction.Publish, AccessLevel.NoAccess);

Can I create one catalog in two languages with different currencies? How?

Inside of this catalog will be categories. They have the same structure: same name, same code, but different languages.

Example structure:

Market1, Market2

CatalogName (DefaultLanguage = Market1.DefaultLanguage, DefaultCurrency = Market1.DefaultCurrency) - CategoryName(Code, Language = Market1.DefaultLanguage)

CatalogName (DefaultLanguage = Market2.DefaultLanguage, DefaultCurrency = Market2.DefaultCurrency) - CategoryName(Code, Language = Market2.DefaultLanguage)

I tried to create one catalog instance for every market. It went well, but it doesnt work for categories since they have unique code

Please help!

#190794
Apr 17, 2018 8:33
Vote:
 

Not sure I understand what you are trying to achieve, but Market works at entry level. Of course you can create catalog per market, but an easier approach would be tie market to language and use market to control which language to display. 

#190807
Apr 17, 2018 12:21
Vote:
 

Thanks, I see your point. Now I got another problem. I create a catalog for market, but then I need to add a language to this catalog. I use:

private void AddLanguageToCatalog(CatalogContent catalog, CultureInfo language)

{

var catalogInstance = catalog.CreateWritableClone() as CatalogContent;

if (catalogInstance != null){

catalogInstance.CatalogLanguages.Add(language.Name);

_contentRepository.Save(catalogInstance, SaveAction.Publish, AccessLevel.NoAccess);

}

}

But I get error: Unable to save catalog content. An existing catalog already have the selected name ''

What is wrong? 

#190814
Apr 17, 2018 13:05
Vote:
 

That's strange. What does your entire code look like

#190857
Apr 17, 2018 17:13
* 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.