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

How to update Available languages on CatalogContent?

Vote:
 

Hi guys,

trying to programatically to update the Available languages for Catalog Content in a Sched.Job.

I have added a new Market and also the language in CMS (Admin -> Manage Website languages)

The Market is es-PA = Panama.

My code
var cloneCatalogCatalogLanguages = cloneCatalog.Property.Get("CatalogLanguages");
(cloneCatalogCatalogLanguages .Value as ItemCollection<string>).Add("es-PA"); 
cloneCatalogCatalogLanguages .Property.Set("CatalogLanguages", dd );
repository.Save(cloneCatalogCatalogLanguages , SaveAction.Publish);

When i go to the Catalog ( cms/Commerce/Catalog)

the Panama language is not checked and the page is not published???
What am i doing wrong?

#207191
Edited, Sep 12, 2019 10:42
Vote:
 

you are doing it wrong, what you can do should be like this

cloneCatalog.CatalogLanguages.Add("es-PA");

repository.Save(cloneCatalog, SaveAction.Publish);

Assuming cloneCatalog is a writeable clone of your catalog content instance 

#207192
Sep 12, 2019 10:57
Vote:
 

thx boss

#207193
Sep 12, 2019 10:58
Vote:
 

Forgot to mention that you must have the new language enabled for your site. You can either use CMS => Admin => Manage Website Languages, or you can use ILanguageBranchRepository to do that programatically 

#207194
Sep 12, 2019 11:09
Vote:
 

Did it already, thank you.

One last part, do not how i could activate the language in CMS, in code.
Let's say i get the start page (or root page) and activate the language and then sett fallback

Any clue what I-Interfaces could do that?

#207201
Sep 12, 2019 13:14
Vote:
 

If I get your correctly then you want to set the fallback setting? If yes then you can look into ContentLanguageSettingRepository. You can load ContentLanguageSettings of a content, add or change the Fallback setting, then save it back

#207202
Sep 12, 2019 13:28
Vote:
 

You did understand me correctly.
I have been searching for that repo for 2h.
Tried everything but, always started with ILang...., Isetti...., IContentLang....
But the Intelillisense did not give me any good hits.

Thanks Quan.

#207203
Sep 12, 2019 14:27
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.