Skip to content

Commit 4f2be11

Browse files
committed
The display order of attribute values are considered in the sorting of backend's attribute combination grid
1 parent 5c858c4 commit 4f2be11

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

src/Plugins/SmartStore.AmazonPay/Services/AmazonPayService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ private Order FindOrder(AmazonPayApiData data)
832832
}
833833

834834
if (errorId.HasValue())
835-
Logger.InsertLog(LogLevel.Error, T("Plugins.Payments.AmazonPay.OrderNotFound", errorId), "");
835+
Logger.InsertLog(LogLevel.Warning, T("Plugins.Payments.AmazonPay.OrderNotFound", errorId), "");
836836

837837
return order;
838838
}

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,6 @@ public ActionResult CrossSellProductAddPopup(int productId)
17281728
}
17291729

17301730
//manufacturers
1731-
// model.AvailableManufacturers.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); // codehint: sm-delete
17321731
foreach (var m in _manufacturerService.GetAllManufacturers(true))
17331732
{
17341733
model.AvailableManufacturers.Add(new SelectListItem() { Text = m.Name, Value = m.Id.ToString() });
@@ -3187,7 +3186,6 @@ public ActionResult TierPriceInsert(GridCommand command, ProductModel.TierPriceM
31873186
ProductId = model.ProductId,
31883187
// use Store property (not Store propertyId) because appropriate property is stored in it
31893188
StoreId = model.Store.ToInt(),
3190-
// codehint: sm-edit
31913189
// use CustomerRole property (not CustomerRoleId) because appropriate property is stored in it
31923190
CustomerRoleId = model.CustomerRole.IsNumeric() && Int32.Parse(model.CustomerRole) != 0 ? Int32.Parse(model.CustomerRole) : (int?)null,
31933191
Quantity = model.Quantity,
@@ -3214,7 +3212,6 @@ public ActionResult TierPriceUpdate(GridCommand command, ProductModel.TierPriceM
32143212
//use Store property (not Store propertyId) because appropriate property is stored in it
32153213
tierPrice.StoreId = model.Store.ToInt();
32163214
//use CustomerRole property (not CustomerRoleId) because appropriate property is stored in it
3217-
// codehint: sm-edit
32183215
tierPrice.CustomerRoleId = model.CustomerRole.IsNumeric() && Int32.Parse(model.CustomerRole) != 0 ? Int32.Parse(model.CustomerRole) : (int?)null;
32193216
tierPrice.Quantity = model.Quantity;
32203217
tierPrice.Price = model.Price1;
@@ -3855,7 +3852,6 @@ public ActionResult ProductVariantAttributeCombinationList(GridCommand command,
38553852
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
38563853
return AccessDeniedView();
38573854

3858-
// codehint: sm-edit
38593855
// TODO: Replace ProductModel.ProductVariantAttributeCombinationModel by AddProductVariantAttributeCombinationModel
38603856
// when there's no grid-inline-editing anymore.
38613857

@@ -3877,6 +3873,21 @@ public ActionResult ProductVariantAttributeCombinationList(GridCommand command,
38773873
pvacModel.ProductUrl = productUrl + _productAttributeParser.SerializeQueryData(product.Id, x.AttributesXml);
38783874
pvacModel.ProductUrlTitle = productUrlTitle;
38793875

3876+
try
3877+
{
3878+
var firstAttribute = _productAttributeParser.DeserializeProductVariantAttributes(x.AttributesXml).FirstOrDefault();
3879+
3880+
var attribute = x.Product.ProductVariantAttributes.FirstOrDefault(y => y.Id == firstAttribute.Key);
3881+
3882+
var attributeValue = attribute.ProductVariantAttributeValues.FirstOrDefault(y => y.Id == int.Parse(firstAttribute.Value.First()));
3883+
3884+
pvacModel.DisplayOrder = firstAttribute.Key + attributeValue.DisplayOrder;
3885+
}
3886+
catch (Exception exc)
3887+
{
3888+
exc.Dump();
3889+
}
3890+
38803891
//if (x.IsDefaultCombination)
38813892
// pvacModel.AttributesXml = "<b>{0}</b>".FormatWith(pvacModel.AttributesXml);
38823893

@@ -3885,7 +3896,8 @@ public ActionResult ProductVariantAttributeCombinationList(GridCommand command,
38853896
pvacModel.Warnings.AddRange(warnings);
38863897

38873898
return pvacModel;
3888-
}).ToList();
3899+
})
3900+
.OrderBy(x => x.DisplayOrder).ToList();
38893901

38903902
var model = new GridModel<ProductVariantAttributeCombinationModel>
38913903
{

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web.Mvc;
24
using SmartStore.Core.Domain.Catalog;
35
using SmartStore.Web.Framework;
46
using SmartStore.Web.Framework.Mvc;
5-
using System.ComponentModel.DataAnnotations;
6-
using System.Web.Mvc;
77

88
namespace SmartStore.Admin.Models.Catalog
99
{
@@ -16,6 +16,7 @@ public ProductVariantAttributeCombinationModel()
1616
AssignablePictures = new List<PictureSelectItemModel>();
1717
AvailableDeliveryTimes = new List<SelectListItem>();
1818
Warnings = new List<string>();
19+
DisplayOrder = 0;
1920
}
2021

2122
[SmartResourceDisplayName("Admin.Catalog.Products.ProductVariantAttributes.AttributeCombinations.Fields.StockQuantity")]
@@ -74,6 +75,8 @@ public ProductVariantAttributeCombinationModel()
7475
public string ProductUrl { get; set; }
7576
public string ProductUrlTitle { get; set; }
7677

78+
public long DisplayOrder { get; set; }
79+
7780
[AllowHtml]
7881
public IList<string> Warnings { get; set; }
7982

0 commit comments

Comments
 (0)