Skip to content

Commit a74dfd1

Browse files
Added quantity unit management
1 parent 8a23760 commit a74dfd1

49 files changed

Lines changed: 1235 additions & 58 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ public CatalogSettings()
323323

324324
public int? LabelAsNewForMaxDays { get; set; }
325325

326+
public bool ShowDefaultQuantityUnit { get; set; }
327+
326328
public bool ShowDiscountSign { get; set; }
327329

328330
public bool SuppressSkuSearch { get; set; }

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public partial class Product : BaseEntity, ISoftDeletable, ILocalizedEntity, ISl
3737
private string _manufacturerPartNumber;
3838
private decimal _price;
3939
private int? _deliveryTimeId;
40+
private int? _quantityUnitId;
4041
private decimal _length;
4142
private decimal _width;
4243
private decimal _height;
@@ -697,6 +698,27 @@ public int? DeliveryTimeId
697698
[DataMember]
698699
public virtual DeliveryTime DeliveryTime { get; set; }
699700

701+
/// <summary>
702+
/// Gets or sets the delivery time identifier
703+
/// </summary>
704+
[DataMember]
705+
public int? QuantityUnitId
706+
{
707+
[DebuggerStepThrough]
708+
get
709+
{
710+
return this.GetMergedDataValue<int?>("QuantityUnitId", _quantityUnitId);
711+
}
712+
set
713+
{
714+
_quantityUnitId = value;
715+
}
716+
}
717+
718+
[DataMember]
719+
public virtual QuantityUnit QuantityUnit { get; set; }
720+
721+
700722
/// <summary>
701723
/// Gets or sets if base price quotation (PAnGV) is enabled
702724
/// </summary>
@@ -711,7 +733,7 @@ public int? DeliveryTimeId
711733

712734
/// <summary>
713735
/// Amount of product per packing unit in the given measure unit
714-
/// (e.g. 250 ml shower gel: "0.25" if MeasureUnit = "liter" and BaseAmount = 1)
736+
/// (e.g. 250 ml shower gel: "0.25" if MeasureUnit = "liter" and BaseAmount = 1)
715737
/// </summary>
716738
[DataMember]
717739
public decimal? BasePriceAmount

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public ProductVariantAttributeCombination()
5151
[DataMember]
5252
public virtual DeliveryTime DeliveryTime { get; set; }
5353

54+
[DataMember]
55+
public int? QuantityUnitId { get; set; }
56+
57+
[DataMember]
58+
public virtual QuantityUnit QuantityUnit { get; set; }
59+
5460
[DataMember]
5561
public bool IsActive { get; set; }
5662
//public bool IsDefaultCombination { get; set; }

src/Libraries/SmartStore.Core/Domain/Directory/DeliveryTime.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ public partial class DeliveryTime : BaseEntity, ILocalizedEntity
2828
[DataMember]
2929
public string DisplayLocale { get; set; }
3030

31-
/// <summary>
32-
/// Gets or sets a value indicating whether the entity is published
33-
/// </summary>
34-
//public virtual bool Published { get; set; }
35-
3631
/// <summary>
3732
/// Gets or sets the display order
3833
/// </summary>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using SmartStore.Core.Domain.Localization;
3+
using System.Runtime.Serialization;
4+
5+
namespace SmartStore.Core.Domain.Directory
6+
{
7+
/// <summary>
8+
/// Represents a currency
9+
/// </summary>
10+
[DataContract]
11+
public partial class QuantityUnit : BaseEntity, ILocalizedEntity
12+
{
13+
/// <summary>
14+
/// Gets or sets the name
15+
/// </summary>
16+
[DataMember]
17+
public string Name { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the hex value
21+
/// </summary>
22+
[DataMember]
23+
public string Description { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets the display locale
27+
/// </summary>
28+
[DataMember]
29+
public string DisplayLocale { get; set; }
30+
31+
/// <summary>
32+
/// Gets or sets the display order
33+
/// </summary>
34+
[DataMember]
35+
public int DisplayOrder { get; set; }
36+
37+
/// <summary>
38+
/// Gets or sets the default quantity unit
39+
/// </summary>
40+
[DataMember]
41+
public bool IsDefault { get; set; }
42+
43+
}
44+
}

src/Libraries/SmartStore.Core/SmartStore.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
<Compile Include="Caching\ICache.cs" />
155155
<Compile Include="Collections\QuerystringBuilder.cs" />
156156
<Compile Include="Collections\TopologicalSorter.cs" />
157+
<Compile Include="Domain\Directory\QuantityUnit.cs" />
157158
<Compile Include="Domain\Seo\CanonicalHostNameRule.cs" />
158159
<Compile Include="Extensions\IOExtensions.cs" />
159160
<Compile Include="Extensions\DecimalExtensions.cs" />

src/Libraries/SmartStore.Data/Mapping/Catalog/ProductMap.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public ProductMap()
3737
.HasForeignKey(p => p.DeliveryTimeId)
3838
.WillCascadeOnDelete(false);
3939

40+
this.HasOptional(p => p.QuantityUnit)
41+
.WithMany()
42+
.HasForeignKey(p => p.QuantityUnitId)
43+
.WillCascadeOnDelete(false);
44+
4045
this.HasOptional(p => p.SampleDownload)
4146
.WithMany()
4247
.HasForeignKey(p => p.SampleDownloadId)

src/Libraries/SmartStore.Data/Mapping/Catalog/ProductVariantAttributeCombinationMap.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public ProductVariantAttributeCombinationMap()
2828
.WithMany()
2929
.HasForeignKey(pvac => pvac.DeliveryTimeId)
3030
.WillCascadeOnDelete(false);
31+
this.HasOptional(pvac => pvac.QuantityUnit)
32+
.WithMany()
33+
.HasForeignKey(pvac => pvac.QuantityUnitId)
34+
.WillCascadeOnDelete(false);
35+
3136
}
3237
}
3338
}

src/Libraries/SmartStore.Data/Mapping/Directory/DeliveryTimeMap.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public DeliveryTimeMap()
1212
this.Property(c => c.Name).IsRequired().HasMaxLength(50);
1313
this.Property(c => c.ColorHexValue).IsRequired().HasMaxLength(50);
1414
this.Property(c => c.DisplayLocale).HasMaxLength(50);
15-
//this.Property(c => c.Published);
1615
this.Property(c => c.DisplayOrder);
1716
}
1817
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Data.Entity.ModelConfiguration;
2+
using SmartStore.Core.Domain.Directory;
3+
4+
namespace SmartStore.Data.Mapping.Directory
5+
{
6+
public partial class QuantityUnitMap : EntityTypeConfiguration<QuantityUnit>
7+
{
8+
public QuantityUnitMap()
9+
{
10+
this.ToTable("QuantityUnit");
11+
this.HasKey(c => c.Id);
12+
this.Property(c => c.Name).IsRequired().HasMaxLength(50);
13+
this.Property(c => c.Description).IsRequired().HasMaxLength(50);
14+
this.Property(c => c.DisplayLocale).HasMaxLength(50);
15+
this.Property(c => c.DisplayOrder);
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)