Skip to content

Commit bc39400

Browse files
committed
Hidden attribute options (in progress)
1 parent f19055b commit bc39400

12 files changed

Lines changed: 244 additions & 12 deletions

File tree

src/Libraries/SmartStore.Core/Domain/Catalog/Product.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ public decimal Price
592592
[DataMember]
593593
public decimal? LowestAttributeCombinationPrice { get; set; }
594594

595+
/// <summary>
596+
/// Gets or sets a value indicating whether to hide unavailable attribute combinations. By default, they are disabled.
597+
/// </summary>
598+
[DataMember]
599+
public bool HideUnavailableAttributes { get; set; }
600+
595601
/// <summary>
596602
/// Gets or sets a value indicating whether this product has discounts applied
597603
/// <remarks>The same as if we run this.AppliedDiscounts.Count > 0

src/Libraries/SmartStore.Core/Domain/Catalog/ProductVariantAttribute.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.ComponentModel.DataAnnotations;
23
using System.ComponentModel.DataAnnotations.Schema;
34
using System.Runtime.Serialization;
45
using SmartStore.Core.Domain.Localization;
@@ -32,6 +33,14 @@ public partial class ProductVariantAttribute : BaseEntity, ILocalizedEntity
3233
[DataMember]
3334
public string TextPrompt { get; set; }
3435

36+
/// <summary>
37+
/// Gets or sets any custom data.
38+
/// It's not used by Smartstore but is being passed to the choice partial view.
39+
/// </summary>
40+
[DataMember]
41+
[MaxLength]
42+
public string CustomData { get; set; }
43+
3544
/// <summary>
3645
/// Gets or sets a value indicating whether the entity is required
3746
/// </summary>

src/Libraries/SmartStore.Core/Domain/Catalog/ProductVariantAttributeCombination.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.ComponentModel.DataAnnotations.Schema;
12
using System.Runtime.Serialization;
23
namespace SmartStore.Core.Domain.Catalog
34
{
@@ -23,12 +24,14 @@ public partial class ProductVariantAttributeCombination : BaseEntity
2324
/// Gets or sets the stock quantity
2425
/// </summary>
2526
[DataMember]
27+
[Index("IX_StockQuantity_AllowOutOfStockOrders", 1)]
2628
public int StockQuantity { get; set; }
2729

2830
/// <summary>
2931
/// Gets or sets a value indicating whether to allow orders when out of stock
3032
/// </summary>
3133
[DataMember]
34+
[Index("IX_StockQuantity_AllowOutOfStockOrders", 2)]
3235
public bool AllowOutOfStockOrders { get; set; }
3336

3437
/// <summary>

src/Libraries/SmartStore.Data/Migrations/202010011823075_HideUnavailableAttributes.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace SmartStore.Data.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
6+
public partial class HideUnavailableAttributes : DbMigration
7+
{
8+
public override void Up()
9+
{
10+
AddColumn("dbo.Product", "HideUnavailableAttributes", c => c.Boolean(nullable: false));
11+
AddColumn("dbo.Product_ProductAttribute_Mapping", "CustomData", c => c.String());
12+
CreateIndex("dbo.ProductVariantAttributeCombination", new[] { "StockQuantity", "AllowOutOfStockOrders" });
13+
}
14+
15+
public override void Down()
16+
{
17+
DropIndex("dbo.ProductVariantAttributeCombination", new[] { "StockQuantity", "AllowOutOfStockOrders" });
18+
DropColumn("dbo.Product_ProductAttribute_Mapping", "CustomData");
19+
DropColumn("dbo.Product", "HideUnavailableAttributes");
20+
}
21+
}
22+
}

src/Libraries/SmartStore.Data/Migrations/202010011823075_HideUnavailableAttributes.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ können aber nicht bearbeitet werden. Die Texte dieser Informationen können üb
593593
"'Bundesland' erferderlich",
594594
"Check the box if 'State/province' is required.",
595595
"Legt fest, ob Angaben im Eingabefeld 'Adressszusatz' erforderlich sind.");
596+
597+
builder.AddOrUpdate("Admin.Catalog.Products.Fields.HideUnavailableAttributes",
598+
"Hide unavailable attribute combinations",
599+
"Nicht verfügbare Attribut-Kombinationen ausblenden",
600+
"Specifies whether to hide unavailable attribute combinations on product detail pages. By default, they are disabled.",
601+
"Legt fest, ob nicht verfügbare Attribut-Kombinationen auf Produktdetailseiten ausgeblendet werden sollen. Standardmäßig werden sie deaktiviert.");
596602

597603
#region Media
598604

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@
521521
<Compile Include="Migrations\202010011005387_TopicCookieType.designer.cs">
522522
<DependentUpon>202010011005387_TopicCookieType.cs</DependentUpon>
523523
</Compile>
524+
<Compile Include="Migrations\202010011823075_HideUnavailableAttributes.cs" />
525+
<Compile Include="Migrations\202010011823075_HideUnavailableAttributes.designer.cs">
526+
<DependentUpon>202010011823075_HideUnavailableAttributes.cs</DependentUpon>
527+
</Compile>
524528
<Compile Include="ObjectContextBase.SaveChanges.cs" />
525529
<Compile Include="Setup\Builder\ActivityLogTypeMigrator.cs" />
526530
<Compile Include="Setup\Builder\SettingsBuilder.cs" />
@@ -938,6 +942,9 @@
938942
<EmbeddedResource Include="Migrations\202010011005387_TopicCookieType.resx">
939943
<DependentUpon>202010011005387_TopicCookieType.cs</DependentUpon>
940944
</EmbeddedResource>
945+
<EmbeddedResource Include="Migrations\202010011823075_HideUnavailableAttributes.resx">
946+
<DependentUpon>202010011823075_HideUnavailableAttributes.cs</DependentUpon>
947+
</EmbeddedResource>
941948
<EmbeddedResource Include="Sql\Indexes.sql" />
942949
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
943950
</ItemGroup>

src/Presentation/SmartStore.Web/Administration/Controllers/ProductController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ protected void UpdateProductPrice(Product product, ProductModel model)
431431
}
432432
}
433433

434+
[NonAction]
435+
protected void UpdateProductAttributes(Product product, ProductModel model)
436+
{
437+
product.HideUnavailableAttributes = model.HideUnavailableAttributes;
438+
}
439+
434440
[NonAction]
435441
protected void UpdateProductSeo(Product product, ProductModel model)
436442
{
@@ -1277,6 +1283,9 @@ protected void MapModelToProduct(ProductModel model, Product product, FormCollec
12771283
case "price":
12781284
UpdateProductPrice(product, model);
12791285
break;
1286+
case "attributes":
1287+
UpdateProductAttributes(product, model);
1288+
break;
12801289
case "downloads":
12811290
UpdateProductDownloads(product, model);
12821291
break;

src/Presentation/SmartStore.Web/Administration/Models/Catalog/ProductModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ public ProductModel()
353353
[SmartResourceDisplayName("Admin.Catalog.Products.Fields.BundlePerItemShoppingCart")]
354354
public bool BundlePerItemShoppingCart { get; set; }
355355

356+
[SmartResourceDisplayName("Admin.Catalog.Products.Fields.HideUnavailableAttributes")]
357+
public bool HideUnavailableAttributes { get; set; }
358+
356359
public string PrimaryStoreCurrencyCode { get; set; }
357360
public string BaseDimensionIn { get; set; }
358361
public string BaseWeightIn { get; set; }

0 commit comments

Comments
 (0)