Entry-level localization & querying for entries for specific locale

Hi there,

I have a Contentful environment setup with two locales (“en-US” - default & “it”).

After realising that field-level localization is not going to provide the asynchronous approach we need for localization I am in the process of implementing entry-level localization (as per https://www.contentful.com/developers/docs/concepts/locales/#entry-level-localization).

I have created two test global entries (“postGlobal”), one with a single localized reference to a local entry (“postLocal”) for the “it” locale, the other with a single localized reference to a local entry for the “en-US” locale.

Both my content types (“postGlobal” and “postLocal”) are effectively the same as “articleGlobal” and “articleLocal” referenced in the article above.

I am now trying to query the global entries using the PHP SDK, and only access those that have localized references for the “it” locale. Unfortunately my query is returning both global entries which is causing issues.

My question is: is there a way in my query to only fetch “postGlobal” entries that have “postLocal” references for the “it” locale?

My current query is:

$query = new \Contentful\Delivery\Query();


First a question: does it fallback to en-US?

As long as it doesn’t fallback, you can look for all the global posts for which the localized field exists for the it locale. So something like this:

$query = new \Contentful\Delivery\Query();
    ->where('fields.localized', 'true', 'exists')

Hi Charlie,

No, it doesn’t fallback to en-US.

I have just implemented your suggestion and it’s working perfectly - thank you so much for your help!