Skip to content

Commit

Permalink
VCST-2486: Breadcrumbs localization (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegoO authored Jan 31, 2025
1 parent 0a5ad5f commit afe378b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/VirtoCommerce.XCatalog.Core/Extensions/OutlineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static IEnumerable<Breadcrumb> GetBreadcrumbsFromOutLine(this IEnumerable
var breadcrumb = new Breadcrumb(item.SeoObjectType)
{
ItemId = item.Id,
Title = seoInfoForStoreAndLanguage?.PageTitle?.EmptyToNull() ?? item.Name,
Title = ResolveItemTitle(item, seoInfoForStoreAndLanguage, cultureName),
SemanticUrl = seoInfoForStoreAndLanguage?.SemanticUrl,
SeoPath = seoPath
};
Expand All @@ -172,6 +172,22 @@ public static IEnumerable<Breadcrumb> GetBreadcrumbsFromOutLine(this IEnumerable
return breadcrumbs;
}

private static string ResolveItemTitle(OutlineItem item, SeoInfo seoInfoForStoreAndLanguage, string cultureName)
{
var pageTitle = seoInfoForStoreAndLanguage?.PageTitle?.EmptyToNull();
if (!string.IsNullOrEmpty(pageTitle))
{
return pageTitle;
}

if (item.LocalizedName != null && item.LocalizedName.TryGetValue(cultureName, out var localizedTitle))
{
return localizedTitle;
}

return item.Name;
}

public static SeoInfo SeoInfoForStoreAndLanguage(OutlineItem item, string storeId, string cultureName)
{
return item.SeoInfos?.FirstOrDefault(x => x.StoreId == storeId && x.LanguageCode == cultureName);
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.XCatalog.Core/Schemas/CategoryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CategoryType(IMediator mediator, IDataLoaderContextAccessor dataLoader)
{
var cultureName = context.GetArgumentOrValue<string>("cultureName");
var category = context.Source.Category;
var localizedName = category.LocalizedName?.Get(cultureName);
var localizedName = category.LocalizedName?.GetValue(cultureName);
if (!string.IsNullOrEmpty(localizedName))
{
return localizedName;
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.XCatalog.Core/Schemas/ProductType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ProductType(IMediator mediator, IDataLoaderContextAccessor dataLoader)
{
var cultureName = context.GetArgumentOrValue<string>("cultureName");
var product = context.Source.IndexedProduct;
var localizedName = product.LocalizedName?.Get(cultureName);
var localizedName = product.LocalizedName?.GetValue(cultureName);
if (!string.IsNullOrEmpty(localizedName))
{
return localizedName;
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.900.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.837.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.839.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 @@ -4,9 +4,9 @@
<version>3.901.0</version>
<version-tag></version-tag>

<platformVersion>3.867.0</platformVersion>
<platformVersion>3.877.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Catalog" version="3.837.0" />
<dependency id="VirtoCommerce.Catalog" version="3.839.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

0 comments on commit afe378b

Please sign in to comment.