Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Culture and LocalizationSet are not set for LocalizationPart if content is created programmatically #15713

Closed
M-Lipin opened this issue Apr 10, 2024 · 10 comments · Fixed by #15714
Labels

Comments

@M-Lipin
Copy link
Contributor

M-Lipin commented Apr 10, 2024

Describe the bug

Culture and LocalizationSet are not set for LocalizationPart if content is created programmatically.

To Reproduce

Steps to reproduce the behavior:

  1. Create some content with LocalizationPart programmatically without specifying Culture and LocalizationSet.
  2. Navigate to the list of contents.
  3. Observe the newly created content.

Expected behavior

Localization settings are available for newly created content.

Screenshots

Localization settings are not available for newly created content.
image

@M-Lipin M-Lipin changed the title Culture and LocalizationSet not created on LocalizationPart creating via GraphQL mutation Culture and LocalizationSet are not set for LocalizationPart if content is created programmatically Apr 11, 2024
@hishamco
Copy link
Member

Create some content with LocalizationPart programmatically without specifying Culture and LocalizationSet.

Can you show me how you create your content programatically?

@M-Lipin
Copy link
Contributor Author

M-Lipin commented Apr 16, 2024

This can be done for instance via custom mutation:

        Resolver = new AsyncFieldResolver<object, ContentItem>(async (context) =>
        {
            var modelValues = context.GetArgument<object>(ModelArgument);
            var contentManager = httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IContentManager>();
            var contentItem = await contentManager.NewAsync(contentType);

            inputGraphType.Enrich(contentItem, modelValues);

            var result = await contentManager.UpdateValidateAndCreateAsync(contentItem, VersionOptions.Draft);
            if (!result.Succeeded)
            {
                context.Errors.AddRange(result.Errors.Select(err =>
                    new ExecutionError(err.ErrorMessage!)));
                return null;
            }
            
            return contentItem;

@hishamco
Copy link
Member

I thought you create it via a normal migration

@M-Lipin
Copy link
Contributor Author

M-Lipin commented Apr 22, 2024

Is there any chance to approve related MR #15714?

@hishamco
Copy link
Member

I'm still waiting for a unit test or I code snippet to reproduce the issue

@Piedone
Copy link
Member

Piedone commented May 2, 2024

The above code snippet should be enough, Hisham.

@hishamco
Copy link
Member

hishamco commented May 2, 2024

I will try to create another migration for a content type that has a LocalizationPart then check, unless you see that changes are fine please approve

@Piedone
Copy link
Member

Piedone commented May 2, 2024

Please do that.

@hishamco
Copy link
Member

hishamco commented May 2, 2024

I already did and approved the PR

@Piedone
Copy link
Member

Piedone commented May 2, 2024

Great then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants