Skip to content

Commit

Permalink
VCST-2485: Enhance localization support for category and product names (
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegoO authored Jan 23, 2025
1 parent 59afb5f commit fc5af2f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/VirtoCommerce.XCatalog.Core/Schemas/CategoryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ public CategoryType(IMediator mediator, IDataLoaderContextAccessor dataLoader)
Field(x => x.Id, nullable: false).Description("Id of category.");
Field(x => x.Category.ImgSrc, nullable: true).Description("The category image.");
Field(x => x.Category.Code, nullable: false).Description("SKU of category.");
Field(x => x.Category.Name, nullable: false).Description("Name of category.");
Field<NonNullGraphType<StringGraphType>>("name", resolve: context =>
{
var cultureName = context.GetArgumentOrValue<string>("cultureName");
var category = context.Source.Category;
var localizedName = category.LocalizedName?.Get(cultureName);
if (!string.IsNullOrEmpty(localizedName))
{
return localizedName;
}
return category.Name;
}, description: "The name of the category.");

Field(x => x.Level, nullable: false).Description("Level in hierarchy");
Field(x => x.Category.Priority, nullable: false).Description("The category priority.");
Field(x => x.RelevanceScore, nullable: true).Description("Category relevance score");
Expand Down
12 changes: 11 additions & 1 deletion src/VirtoCommerce.XCatalog.Core/Schemas/ProductType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,17 @@ public ProductType(IMediator mediator, IDataLoaderContextAccessor dataLoader)
return response.Slug;
}, description: "Request related slug for product");

Field(d => d.IndexedProduct.Name, nullable: false).Description("The name of the product.");
Field<NonNullGraphType<StringGraphType>>("name", resolve: context =>
{
var cultureName = context.GetArgumentOrValue<string>("cultureName");
var product = context.Source.IndexedProduct;
var localizedName = product.LocalizedName?.Get(cultureName);
if (!string.IsNullOrEmpty(localizedName))
{
return localizedName;
}
return product.Name;
}, description: "The name of the product.");

ExtendableField<NonNullGraphType<SeoInfoType>>("seoInfo", resolve: context =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.815.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.830.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.837.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.805.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.815.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.809.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/VirtoCommerce.XCatalog.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<platformVersion>3.867.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Catalog" version="3.830.0" />
<dependency id="VirtoCommerce.Catalog" version="3.837.0" />
<dependency id="VirtoCommerce.Inventory" version="3.805.0" optional="true" />
<dependency id="VirtoCommerce.Marketing" version="3.815.0" optional="true" />
<dependency id="VirtoCommerce.Pricing" version="3.809.0" optional="true" />
Expand Down Expand Up @@ -45,7 +45,7 @@
<moduleType>VirtoCommerce.XCatalog.Web.Module, VirtoCommerce.XCatalog.Web</moduleType>

<releaseNotes>First version.</releaseNotes>
<copyright>Copyright © 2024 VirtoCommerce. All rights reserved</copyright>
<copyright>Copyright © 2025 VirtoCommerce. All rights reserved</copyright>
<tags>extension module</tags>
<useFullTypeNameInSwagger>false</useFullTypeNameInSwagger>
</module>

0 comments on commit fc5af2f

Please sign in to comment.