I'm trying to get an item from database then publish it via code. The item only has pt-pt language (portugal)
I'm using Database.GetDatabase, when I try to get the item from the database. It gives me an item that has en language.
Item item = Database.GetDatabase("master").GetItem(guid);
Then when I try to edit the item using Editing.BeginEdit(), it edits the en version then proceeds to publish it.
Is there a way to get the pt-PT version then edit that version instead of en?
Each item can contain multiple languages. You can use the
Sitecore.Globalization.Languageclass to specify a language when accessing an item using theSitecore.Data.Database.GetItem()method. For example, to access the current version of the/Sitecore/Content/Homeitem in the defaultenlanguage:If you do not specify a language, Sitecore uses the context language by default. Sitecore user interface components specify the content language.
You can use the
Sitecore.Data.Items.Item.Versions.Countproperty to determine if any versions exist for a language. For example, to access the current version in each language of the /Sitecore/Content/Homeitem in the Master database: