Regarding the language fallback for a page, ( as mentioned here in your user guide ) can I disable it programatically?
My site has 2 languages, en-NZ and en-AU.
I have a scheduled job that adds 'ProductPage' content under a 'CategoryPage'. I need the parent page (CategoryPage) to be in en-AU and this needs to be the fallback language for en-NZ. Product pages created under it need to be available in either Australia (en-AU) or New Zealand (en-NZ), or both.
My problem is that each 'ProductPage' is getting created with language settings marked as 'Inherit settings from the parent page', so products that are not available in en-NZ are allowed to fallback to en-AU... but I don't want this.
Is there a way to prevent a page from inheriting its fallback language (without unticking it in the cms)?
I appreciate any help
Looks like I may have solved this by setting
productPage.MasterLanguage = null;
Check out MasterLanguage and MasterLanguageBranch in the PageData class which your ProductPage would be inheriting https://world.episerver.com/documentation/class-library/?documentId=cms/7/b38e303b-a955-4dc6-4bd0-d954c4815ea2
This kinda worked... but pages that were not published in NZ were 'falling back' to AU.
I was able to prevent the page from 'falling back' by updating:
var languageSpecificProductPage = _contentRepository.CreateLanguageBranch<ProductPage>(content, new LanguageSelector("en-NZ"));
var languageSpecificProductPage = _contentRepository.CreateLanguageBranch<ProductPage>(content, LanguageSelector.Fallback(preferredLanguageBranch: language.Name, enableMasterLanguageFallback: false));