Hello everyone, I hope you're fine! 🤗
I'm currently struggling to understand if it's an expected behavior or not. I have a Product collection including a slug (which is generated based on the name of the product).
I wanted to have localized slugs to match the name in the user's language. But if the content is not set in one language I was expecting to be able to find the product anyway with the slug in the fallback language.
Is that something that should work?
const product = await payload.find({
collection: 'products',
locale: 'fr',
fallbackLocale: 'en',
where: { slug: { equals: slug } },
limit: 1,
});
Or is that not really logical? How would you manage this case?
Thanks
A LOT!🙏
Ouuuuh, smart and elegant! Indeed, I didn't think it this way!
Thanks for the confirmation and the nice solution!
Nope!
fallbackLocale
isn't really used in querying, only for the result transformation.
I would have an array field like
slugs
with
locale
and
value
properties, with it you would be more free on querying. You should synchronize it with hooks with your
slug
.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.