Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Smartstore.Core/Migrations/SmartDbContextDataSeeder.cs
  • Loading branch information
mgesing committed Sep 9, 2024
2 parents 92e7761 + 5b3c115 commit 106b386
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- #1129: Extend the PrivacySettings CookieConsentRequirement option to include Switzerland when choosing the option RequiredInEUCountriesOnly
- #762 CookieManager: Scripts are now loaded immediately after consent without refreshing the page.
- #783 Add a field to shipment entity for the name of the cargo company.
- #1176 Avoid duplicate assignment of description on the product page

### Improvements

Expand Down
36 changes: 28 additions & 8 deletions src/Smartstore.Core/Migrations/SmartDbContextDataSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
builder.AddOrUpdate("Admin.Rules.AddRuleWarning", "Please add a rule first.", "Bitte zuerst eine Regel hinzufügen.");

builder.AddOrUpdate("Admin.Rules.AddCondition", "Add rule", "Regel hinzufügen");
builder.AddOrUpdate("Admin.Rules.AllConditions",
"<span>If</span> {0} <span>of the following rules are true.</span>",
builder.AddOrUpdate("Admin.Rules.AllConditions",
"<span>If</span> {0} <span>of the following rules are true.</span>",
"<span>Wenn</span> {0} <span>der folgenden Regeln erfüllt sind.</span>");

builder.AddOrUpdate("Admin.Rules.OneCondition",
Expand All @@ -169,7 +169,7 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Regeln können erst nach einem Speichern festgelegt werden.");

builder.AddOrUpdate("Admin.Rules.TestConditions").Value("de", "Regeln {0} Testen {1}");

builder.AddOrUpdate("Admin.Rules.EditRuleSet", "Edit rule set", "Regelsatz bearbeiten");
builder.AddOrUpdate("Admin.Rules.OpenRuleSet", "Open rule set", "Regelsatz öffnen");
builder.Delete(
Expand Down Expand Up @@ -286,7 +286,7 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Auf der Seite zur Passwort-Wiederherstellung anzeigen");

builder.Delete("Admin.ContentManagement.Topics.Validation.NoWhiteSpace");

builder.AddOrUpdate("Admin.Common.HtmlId.NoWhiteSpace",
"Spaces are invalid for the HTML attribute 'id'.",
"Leerzeichen sind für das HTML-Attribut 'id' ungültig.");
Expand Down Expand Up @@ -340,7 +340,7 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Minimale Produktanzahl für Suche",
"Specifies the minimum number of associated products from which the search field is displayed.",
"Legt die Mindestanzahl verknüpfter Produkte fest, ab denen das Suchfeld angezeigt wird.");

builder.AddOrUpdate("Admin.Catalog.Products.GroupedProductConfiguration.Collapsible",
"Collapsible associated products",
"Aufklappbare verknüpfte Produkte",
Expand Down Expand Up @@ -379,8 +379,8 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"To edit, please first save the product as a grouped product.",
"Zur Bearbeitung bitte zunächst das Produkt als Gruppenprodukt speichern.");

builder.AddOrUpdate("Admin.Catalog.Products.GroupedProductConfiguration.Title",
"Title of associated products list",
builder.AddOrUpdate("Admin.Catalog.Products.GroupedProductConfiguration.Title",
"Title of associated products list",
"Listentitel der verknüpften Produkte");

builder.AddOrUpdate("Admin.Catalog.Products.GroupedProductConfiguration", "Edit grouped product", "Gruppenprodukt bearbeiten");
Expand Down Expand Up @@ -453,6 +453,26 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Three-letter country code according to ISO 3166.",
"Dreibuchstabiges Länderkürzel nach ISO 3166.");

builder.AddOrUpdate("Admin.Configuration.Settings.GeneralCommon.ProductDescriptionPriority",
"Priority of product descriptions",
"Vorrang von Produktbeschreibungen",
"Specifies which 'description' is read by search engines as description content for rich snippets. " +
"If the description selected here is not stored in the product, the other one is automatically marked as 'description', if available.",
"Bestimmt, welche Beschreibung von Suchmaschinen als 'description'-Inhalt für Rich Snippets ausgelesen wird. " +
"Wenn die hier gewählte Beschreibung nicht im Produkt hinterlegt ist, wird automatisch die andere als 'description' gekennzeichnet, sofern vorhanden.");

builder.AddOrUpdate("Enums.ProductDescriptionPriority.FullDescription",
"Full description",
"Langtext");

builder.AddOrUpdate("Enums.ProductDescriptionPriority.ShortDescription",
"Short description",
"Kurzbeschreibung");

builder.AddOrUpdate("Enums.ProductDescriptionPriority.Both",
"Full and short description",
"Langtext und Kurzbeschreibung");

AddAIResources(builder);
}

Expand Down Expand Up @@ -492,7 +512,7 @@ private static void AddAIResources(LocaleResourcesBuilder builder)
"Do not number the suggestions.",
"Nummeriere die Vorschläge nicht.");
builder.AddOrUpdate("Smartstore.AI.Prompts.CharLimitSuggestions",
"Maximum {0} characters per suggestion.",
"Maximum {0} characters per suggestion.",
"Maximal {0} Zeichen pro Vorschlag.");
builder.AddOrUpdate("Smartstore.AI.Prompts.SeparateWithNumberSign",
"Always separate each suggestion with the # sign.",
Expand Down
23 changes: 23 additions & 0 deletions src/Smartstore.Core/Platform/Seo/Configuration/SeoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ public enum TrailingSlashRule
Disallow
}

/// <summary>
/// Represents the prioritization of the schema.org description tag on product pages.
/// </summary>
public enum ProductDescriptionPriority
{
/// <summary>
/// Use the product's full description, if available.
/// </summary>
FullDescription = 0,

/// <summary>
/// Use the product's short description, if available.
/// </summary>
ShortDescription = 1,

/// <summary>
/// Use both the product's short and full description.
/// </summary>
Both = 2
}

public class SeoSettings : ISettings
{
public static ISet<string> DefaultRobotDisallows { get; } = new HashSet<string>
Expand Down Expand Up @@ -98,6 +119,8 @@ public SeoSettings()

public string MetaRobotsContent { get; set; }

public ProductDescriptionPriority ProductDescriptionPriority { get; set; } = ProductDescriptionPriority.FullDescription;

public bool ConvertNonWesternChars { get; set; } = true;
public bool AllowUnicodeCharsInUrls { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public partial class SeoSettingsModel : ISeoModel
[LocalizedDisplay("*MetaRobotsContent")]
public string MetaRobotsContent { get; set; }

[LocalizedDisplay("*ProductDescriptionPriority")]
public ProductDescriptionPriority ProductDescriptionPriority { get; set; }

[LocalizedDisplay("*ConvertNonWesternChars")]
public bool ConvertNonWesternChars { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@
<div>
<editor asp-for="HomepageSettings" asp-template="SeoModel" />
</div>
<div class="adminRow">
<div class="adminTitle">
<smart-label asp-for="SeoSettings.ProductDescriptionPriority" />
</div>
<div class="adminData">
<setting-editor asp-for="SeoSettings.ProductDescriptionPriority"></setting-editor>
<span asp-validation-for="SeoSettings.ProductDescriptionPriority"></span>
</div>
</div>
<div class="adminRow">
<div class="admin-config-group">
<div class="title">@T("Admin.System.SeNames")</div>
Expand Down
25 changes: 21 additions & 4 deletions src/Smartstore.Web/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ public async Task<IActionResult> ProductDetails(int productId, ProductVariantQue
model.CanonicalUrl = Url.RouteUrl("Product", new { model.SeName }, Request.Scheme);
}

// Determine which description to add the itemprop="description" attribute to, using Model.DescriptionPriority.
switch (_seoSettings.ProductDescriptionPriority)
{
case ProductDescriptionPriority.FullDescription:
model.HasFullDescriptionSchemaProperty = model.FullDescription.Value.HasValue() && _seoSettings.ProductDescriptionPriority == ProductDescriptionPriority.FullDescription;
model.HasShortDescriptionSchemaProperty = !model.HasFullDescriptionSchemaProperty;
break;
case ProductDescriptionPriority.ShortDescription:
model.HasShortDescriptionSchemaProperty = model.ShortDescription.Value.HasValue() && _seoSettings.ProductDescriptionPriority == ProductDescriptionPriority.ShortDescription;
model.HasFullDescriptionSchemaProperty = !model.HasShortDescriptionSchemaProperty;
break;
case ProductDescriptionPriority.Both:
model.HasFullDescriptionSchemaProperty = true;
model.HasShortDescriptionSchemaProperty = true;
break;
}

model.MetaProperties = await model.MapMetaPropertiesAsync();

// Save as recently viewed
Expand Down Expand Up @@ -217,15 +234,15 @@ private async Task PrepareAvailablePaymentMethodsAsync()
if (_paymentSettings.ProductDetailPaymentMethodSystemNames.IsNullOrEmpty())
{
return;
}
}

// Store obtained data in memory cache
var cacheKey = PaymentService.ProductDetailPaymentIcons.FormatInvariant(Services.StoreContext.CurrentStore.Id);
ViewBag.AvailablePaymentMethods = await Services.Cache.GetAsync(cacheKey, () =>
{
// INFO: No Dictonary<string, string> here because key are not unique in the case a provider has multiple icons.
var paymentMethods = new List<(string FriendlyName, string Url)>();
// Get all providers.
var providers = _providerManager.Value.GetAllProviders<IPaymentMethod>();
Expand Down Expand Up @@ -354,9 +371,9 @@ public async Task<IActionResult> AssociatedProducts(int id, int page, string q)
[HttpPost]
public async Task<IActionResult> UpdateProductDetails(
string itemType,
int productId,
int productId,
int? parentProductId,
int bundleItemId,
int bundleItemId,
ProductVariantQuery query)
{
// TODO: (core) UpdateProductDetails action needs some decent refactoring.
Expand Down
2 changes: 2 additions & 0 deletions src/Smartstore.Web/Models/Catalog/ProductDetailsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public partial class ProductDetailsModel : EntityModelBase
public LocalizedValue<string> MetaKeywords { get; set; }
public LocalizedValue<string> MetaDescription { get; set; }
public LocalizedValue<string> MetaTitle { get; set; }
public bool HasShortDescriptionSchemaProperty { get; set; }
public bool HasFullDescriptionSchemaProperty { get; set; }
public string SeName { get; set; }
public string CanonicalUrl { get; set; }
public string UpdateUrl { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!-- Short description -->
@if (Model.ShortDescription.Value.HasValue())
{
<div sm-language-attributes-for="Model.ShortDescription" class="pd-description" itemprop="description">
<div sm-language-attributes-for="Model.ShortDescription" class="pd-description" attr-itemprop='(Model.HasShortDescriptionSchemaProperty, "description")'>
@Html.Raw(Model.ShortDescription)
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
var summary = Model.FullDescription.Value.RemoveHtml().Truncate(300, "...");
<tab sm-title="@T("Products.Details")" sm-name="pd-full-desc" sm-selected="true">
<div sm-language-attributes-for="Model.FullDescription" itemprop="description" class="long-text html-editor-content">
<div sm-language-attributes-for="Model.FullDescription" attr-itemprop='(Model.HasFullDescriptionSchemaProperty, "description")' class="long-text html-editor-content">
<collapsed-content>
@Html.Raw(Model.FullDescription)
</collapsed-content>
Expand Down

0 comments on commit 106b386

Please sign in to comment.