Skip to content

Commit 63e5928

Browse files
committed
Product bundle: Some refactoring and started with new template view for bundled items
1 parent fb7278d commit 63e5928

24 files changed

Lines changed: 574 additions & 147 deletions

File tree

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace SmartStore.Core.Domain.Catalog
66
{
77
[DataContract]
8-
public partial class ProductBundleItem : BaseEntity, ILocalizedEntity, ICloneable
8+
public partial class ProductBundleItem : BaseEntity, ILocalizedEntity, ICloneable<ProductBundleItem>
99
{
1010
/// <summary>
1111
/// Gets or sets the product identifier
@@ -14,10 +14,10 @@ public partial class ProductBundleItem : BaseEntity, ILocalizedEntity, ICloneabl
1414
public int ProductId { get; set; }
1515

1616
/// <summary>
17-
/// Gets or sets the product identifier of the product bundle
17+
/// Gets or sets the product identifier of the bundle product
1818
/// </summary>
1919
[DataMember]
20-
public int ParentBundledProductId { get; set; }
20+
public int BundleProductId { get; set; }
2121

2222
/// <summary>
2323
/// Gets or sets the quantity
@@ -31,24 +31,12 @@ public partial class ProductBundleItem : BaseEntity, ILocalizedEntity, ICloneabl
3131
[DataMember]
3232
public decimal? Discount { get; set; }
3333

34-
/// <summary>
35-
/// Gets or sets a value indicating whether the name should be overwritten
36-
/// </summary>
37-
[DataMember]
38-
public bool OverrideName { get; set; }
39-
4034
/// <summary>
4135
/// Gets or sets the name value
4236
/// </summary>
4337
[DataMember]
4438
public string Name { get; set; }
4539

46-
/// <summary>
47-
/// Gets or sets a value indicating whether the short description should be overwritten
48-
/// </summary>
49-
[DataMember]
50-
public bool OverrideShortDescription { get; set; }
51-
5240
/// <summary>
5341
/// Gets or sets the name value
5442
/// </summary>
@@ -91,21 +79,19 @@ public partial class ProductBundleItem : BaseEntity, ILocalizedEntity, ICloneabl
9179
public virtual Product Product { get; set; }
9280

9381
/// <summary>
94-
/// Gets the parent bundled product
82+
/// Gets the bundle product
9583
/// </summary>
96-
public virtual Product ParentBundledProduct { get; set; }
84+
public virtual Product BundleProduct { get; set; }
9785

98-
public object Clone()
86+
public ProductBundleItem Clone()
9987
{
10088
var bundleItem = new ProductBundleItem()
10189
{
10290
ProductId = this.ProductId,
103-
ParentBundledProductId = this.ParentBundledProductId,
91+
BundleProductId = this.BundleProductId,
10492
Quantity = this.Quantity,
10593
Discount = this.Discount,
106-
OverrideName = this.OverrideName,
10794
Name = this.Name,
108-
OverrideShortDescription = this.OverrideShortDescription,
10995
ShortDescription = this.ShortDescription,
11096
HideThumbnail = this.HideThumbnail,
11197
Published = this.Published,
@@ -115,5 +101,10 @@ public object Clone()
115101
};
116102
return bundleItem;
117103
}
104+
105+
object ICloneable.Clone()
106+
{
107+
return this.Clone();
108+
}
118109
}
119110
}

src/Libraries/SmartStore.Core/Domain/Media/MediaSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class MediaSettings : ISettings
1010
public int ProductDetailsPictureSize { get; set; }
1111
public int ProductThumbPictureSizeOnProductDetailsPage { get; set; }
1212
public int AssociatedProductPictureSize { get; set; }
13+
public int BundledProductPictureSize { get; set; }
1314
public int CategoryThumbPictureSize { get; set; }
1415
public int ManufacturerThumbPictureSize { get; set; }
1516
public int CartThumbPictureSize { get; set; }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public ProductBundleItemMap()
1919
.HasForeignKey(pbi => pbi.ProductId)
2020
.WillCascadeOnDelete(false); // SQL Server does not support multiple cascade deletes
2121

22-
this.HasRequired(pbi => pbi.ParentBundledProduct)
22+
this.HasRequired(pbi => pbi.BundleProduct)
2323
.WithMany()
24-
.HasForeignKey(pbi => pbi.ParentBundledProductId)
24+
.HasForeignKey(pbi => pbi.BundleProductId)
2525
.WillCascadeOnDelete(true);
2626
}
2727
}

src/Libraries/SmartStore.Services/Catalog/CopyProductService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,12 @@ public virtual Product CopyProduct(Product product, string newName, bool isPubli
512512
}
513513

514514
// bundled products
515-
var bundledItems = _productService.GetBundleItemsByParentBundledProductId(product.Id, true);
515+
var bundledItems = _productService.GetBundleItems(product.Id, true);
516516

517517
foreach (var bundledItem in bundledItems)
518518
{
519-
var newBundledItem = (ProductBundleItem)bundledItem.Clone();
520-
newBundledItem.ParentBundledProductId = productCopy.Id;
519+
var newBundledItem = bundledItem.Clone();
520+
newBundledItem.BundleProductId = productCopy.Id;
521521
newBundledItem.CreatedOnUtc = utcNow;
522522
newBundledItem.UpdatedOnUtc = utcNow;
523523

src/Libraries/SmartStore.Services/Catalog/IProductService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ void AdjustInventory(Product product, bool decrease,
291291
/// <summary>
292292
/// Gets a list of bundle items for a particular product identifier
293293
/// </summary>
294-
/// <param name="parentBundledProductId">Product identifier</param>
294+
/// <param name="bundleProductId">Product identifier</param>
295295
/// <param name="showHidden">A value indicating whether to show hidden records</param>
296296
/// <returns>List of bundle items</returns>
297-
IList<ProductBundleItem> GetBundleItemsByParentBundledProductId(int parentBundledProductId, bool showHidden = false);
297+
IList<ProductBundleItem> GetBundleItems(int bundleProductId, bool showHidden = false);
298298

299299
#endregion
300300

src/Libraries/SmartStore.Services/Catalog/ProductService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ public virtual void InsertBundleItem(ProductBundleItem bundleItem)
15231523
if (bundleItem == null)
15241524
throw new ArgumentNullException("bundleItem");
15251525

1526-
if (bundleItem.ParentBundledProductId == 0)
1526+
if (bundleItem.BundleProductId == 0)
15271527
throw new SmartException("ParentBundledProductId of a bundle item can't be 0.");
15281528

15291529
_productBundleItemRepository.Insert(bundleItem);
@@ -1578,15 +1578,15 @@ public virtual ProductBundleItem GetBundleItemById(int bundleItemId)
15781578
/// <summary>
15791579
/// Gets a list of bundle items for a particular product identifier
15801580
/// </summary>
1581-
/// <param name="parentBundledProductId">Product identifier</param>
1581+
/// <param name="bundleProductId">Product identifier</param>
15821582
/// <param name="showHidden">A value indicating whether to show hidden records</param>
15831583
/// <returns>List of bundle items</returns>
1584-
public virtual IList<ProductBundleItem> GetBundleItemsByParentBundledProductId(int parentBundledProductId, bool showHidden = false)
1584+
public virtual IList<ProductBundleItem> GetBundleItems(int bundleProductId, bool showHidden = false)
15851585
{
15861586
var query =
15871587
from pbi in _productBundleItemRepository.Table
15881588
join p in _productRepository.Table on pbi.ProductId equals p.Id
1589-
where pbi.ParentBundledProductId == parentBundledProductId && !p.Deleted && (showHidden || pbi.Published)
1589+
where pbi.BundleProductId == bundleProductId && !p.Deleted && (showHidden || pbi.Published)
15901590
orderby pbi.DisplayOrder
15911591
select pbi;
15921592

src/Libraries/SmartStore.Services/ExportImport/ExportManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,19 +457,17 @@ public virtual string ExportProductsToXml(IList<Product> products)
457457
xmlWriter.WriteEndElement();
458458

459459
xmlWriter.WriteStartElement("ProductBundleItems");
460-
var bundleItems = _productService.GetBundleItemsByParentBundledProductId(product.Id, true);
460+
var bundleItems = _productService.GetBundleItems(product.Id, true);
461461
foreach (var bundleItem in bundleItems)
462462
{
463463
xmlWriter.WriteStartElement("ProductBundleItem");
464464

465465
xmlWriter.WriteElementString("ProductId", null, bundleItem.ProductId.ToString());
466-
xmlWriter.WriteElementString("ParentBundledProductId", null, bundleItem.ParentBundledProductId.ToString());
466+
xmlWriter.WriteElementString("ParentBundledProductId", null, bundleItem.BundleProductId.ToString());
467467
xmlWriter.WriteElementString("Quantity", null, bundleItem.Quantity.ToString());
468468
if (bundleItem.Discount.HasValue)
469469
xmlWriter.WriteElementString("Discount", null, bundleItem.Discount.Value.ToString());
470-
xmlWriter.WriteElementString("OverrideName", null, bundleItem.OverrideName.ToString());
471470
xmlWriter.WriteElementString("Name", null, bundleItem.Name);
472-
xmlWriter.WriteElementString("OverrideShortDescription", null, bundleItem.OverrideShortDescription.ToString());
473471
xmlWriter.WriteElementString("ShortDescription", null, bundleItem.ShortDescription);
474472
xmlWriter.WriteElementString("HideThumbnail", null, bundleItem.HideThumbnail.ToString());
475473
xmlWriter.WriteElementString("Published", null, bundleItem.Published.ToString());

src/Libraries/SmartStore.Services/Installation/InvariantInstallationData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,6 +4432,7 @@ public IList<ISettings> Settings()
44324432
ProductDetailsPictureSize = 300,
44334433
ProductThumbPictureSizeOnProductDetailsPage = 70,
44344434
AssociatedProductPictureSize = 125,
4435+
BundledProductPictureSize = 125,
44354436
CategoryThumbPictureSize = 125,
44364437
ManufacturerThumbPictureSize = 125,
44374438
CartThumbPictureSize = 80,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ public ActionResult BundleItemList(GridCommand command, int productId)
16971697
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
16981698
return AccessDeniedView();
16991699

1700-
var bundleItems = _productService.GetBundleItemsByParentBundledProductId(productId, true);
1700+
var bundleItems = _productService.GetBundleItems(productId, true);
17011701

17021702
var bundleItemsModel = bundleItems.Select(x =>
17031703
{
@@ -1734,7 +1734,7 @@ public ActionResult BundleItemDelete(int id, GridCommand command)
17341734

17351735
_productService.DeleteBundleItem(bundleItem);
17361736

1737-
return BundleItemList(command, bundleItem.ParentBundledProductId);
1737+
return BundleItemList(command, bundleItem.BundleProductId);
17381738
}
17391739

17401740
public ActionResult BundleItemAddPopup(int productId)
@@ -1786,7 +1786,7 @@ public ActionResult BundleItemAddPopup(string btnId, string formId, ProductModel
17861786
var bundleItem = new ProductBundleItem()
17871787
{
17881788
ProductId = model.SelectedProductIds[i],
1789-
ParentBundledProductId = model.ProductId,
1789+
BundleProductId = model.ProductId,
17901790
Quantity = 1,
17911791
Published = true,
17921792
DisplayOrder = i + 1,

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@ public ProductBundleItemModel()
1616
public IList<ProductBundleItemLocalizedModel> Locales { get; set; }
1717

1818
public int ProductId { get; set; }
19-
public int ParentBundledProductId { get; set; }
20-
21-
[SmartResourceDisplayName("Admin.Catalog.Products.BundleItems.Fields.OverrideName")]
22-
public bool OverrideName { get; set; }
19+
public int BundleProductId { get; set; }
2320

2421
[SmartResourceDisplayName("Admin.Catalog.Products.BundleItems.Fields.Name")]
2522
public string Name { get; set; }
2623

27-
[SmartResourceDisplayName("Admin.Catalog.Products.BundleItems.Fields.OverrideShortDescription")]
28-
public bool OverrideShortDescription { get; set; }
29-
3024
[SmartResourceDisplayName("Admin.Catalog.Products.BundleItems.Fields.ShortDescription")]
3125
public string ShortDescription { get; set; }
3226

0 commit comments

Comments
 (0)