Skip to content

Commit fd0c91f

Browse files
committed
Merge branch '2.x' into feature/components
Conflicts: src/Plugins/Api.WebApi/Description.txt src/Plugins/Feed.Froogle/Controllers/FeedFroogleController.cs src/Plugins/Feed.Froogle/Services/GoogleFeedService.cs src/Plugins/Feed.Froogle/Services/IGoogleFeedService.cs src/Plugins/Payments.PayPalStandard/Description.txt src/Plugins/Shipping.FixedRate/Description.txt src/Presentation/SmartStore.Web/Controllers/CatalogController.cs
2 parents 8c96d97 + dda3a5e commit fd0c91f

73 files changed

Lines changed: 1010 additions & 321 deletions

File tree

Some content is hidden

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

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* (Developer) Implemented _IWidgetProvider_. Allows request scoped registration of action routes to be injectable into widget zones. Perfect for custom action filters.
1313
* (Developer) Simple widgets: the model of the parent action view context now gets passed to a widget.
1414
* (Developer) New IoC method ContainerManager.InjectProperties()
15+
* #393 Web API: Implement OData actions for simpler working with product attributes
1516

1617
###Improvements###
1718
* Task Scheduler:
@@ -49,6 +50,7 @@
4950
* Product.DisableBuyButton was never updated when the stock quantity has been increased (e.g. as a result of order canceling)
5051
* Shipping.ByTotal: Fixed matching of rates by choosing the more specific over the common rate
5152
* A grouped product only shows up to 12 associated products
53+
* #405 Billiger feed: Wrong base price exported
5254

5355
##SmartStore.NET 2.0.2#
5456

src/Libraries/SmartStore.Core/Domain/Orders/Events.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ public class MigrateShoppingCartEvent
5151
{
5252
private readonly Customer _fromCustomer;
5353
private readonly Customer _toCustomer;
54+
private readonly int _storeId;
5455

55-
public MigrateShoppingCartEvent(Customer fromCustomer, Customer toCustomer)
56+
public MigrateShoppingCartEvent(Customer fromCustomer, Customer toCustomer, int storeId)
5657
{
5758
_fromCustomer = fromCustomer;
5859
_toCustomer = toCustomer;
60+
_storeId = storeId;
5961
}
6062

6163
public Customer FromCustomer
@@ -67,5 +69,10 @@ public Customer ToCustomer
6769
{
6870
get { return _toCustomer; }
6971
}
72+
73+
public int StoreId
74+
{
75+
get { return _storeId; }
76+
}
7077
}
7178
}

src/Libraries/SmartStore.Core/Extensions/MiscExtensions.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Data.OleDb;
55
using System.Diagnostics;
66
using System.ComponentModel;
7+
using System.Web.Routing;
78
using SmartStore.Core;
89

910
namespace SmartStore
@@ -110,5 +111,32 @@ public static T GetMergedDataValue<T>(this IMergedData mergedData, string key, T
110111

111112
return defaultValue;
112113
}
114+
115+
public static bool IsRouteEqual(this RouteData routeData, string controller, string action)
116+
{
117+
if (routeData == null)
118+
return false;
119+
120+
return routeData.GetRequiredString("controller").IsCaseInsensitiveEqual(controller) && routeData.GetRequiredString("action").IsCaseInsensitiveEqual(action);
121+
}
122+
123+
/// <summary>
124+
/// Append grow if string builder is empty. Append delimiter and grow otherwise.
125+
/// </summary>
126+
/// <param name="sb">Target string builder</param>
127+
/// <param name="grow">Value to append</param>
128+
/// <param name="delimiter">Delimiter to use</param>
129+
public static void Grow(this StringBuilder sb, string grow, string delimiter)
130+
{
131+
Guard.ArgumentNotNull(delimiter, "delimiter");
132+
133+
if (!string.IsNullOrWhiteSpace(grow))
134+
{
135+
if (sb.Length <= 0)
136+
sb.Append(grow);
137+
else
138+
sb.AppendFormat("{0}{1}", delimiter, grow);
139+
}
140+
}
113141
}
114142
}

src/Libraries/SmartStore.Core/Extensions/StringExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,21 @@ public static bool ContainsWhiteSpace(this string value)
360360
return false;
361361
}
362362

363+
/// <summary>
364+
/// Ensure that a string starts with a string.
365+
/// </summary>
366+
/// <param name="value">The target string</param>
367+
/// <param name="startsWith">The string the target string should start with</param>
368+
/// <returns>The resulting string</returns>
369+
[DebuggerStepThrough]
370+
public static string EnsureStartsWith(this string value, string startsWith)
371+
{
372+
Guard.ArgumentNotNull(value, "value");
373+
Guard.ArgumentNotNull(startsWith, "startsWith");
374+
375+
return value.StartsWith(startsWith) ? value : (startsWith + value);
376+
}
377+
363378
/// <summary>
364379
/// Ensures the target string ends with the specified string.
365380
/// </summary>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,20 @@ public partial interface IProductAttributeParser
7373
ProductVariantAttributeCombination FindProductVariantAttributeCombination(Product product, string attributesXml);
7474
ProductVariantAttributeCombination FindProductVariantAttributeCombination(int productId, string attributesXml);
7575

76+
/// <summary>
77+
/// Deserializes attribute data from an URL query string
78+
/// </summary>
79+
/// <param name="jsonData">Json data query string</param>
80+
/// <returns>List items with following structure: Product.Id, ProductAttribute.Id, Product_ProductAttribute_Mapping.Id, ProductVariantAttributeValue.Id</returns>
7681
List<List<int>> DeserializeQueryData(string jsonData);
82+
83+
/// <summary>
84+
/// Serializes attribute data
85+
/// </summary>
86+
/// <param name="productId">Product identifier</param>
87+
/// <param name="attributesXml">Attribute XML string</param>
88+
/// <param name="urlEncode">Whether to URL encode</param>
89+
/// <returns>Json string with attribute data</returns>
7790
string SerializeQueryData(int productId, string attributesXml, bool urlEncode = true);
7891

7992
#endregion

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ public virtual ProductVariantAttributeCombination FindProductVariantAttributeCom
303303
return null;
304304
}
305305

306+
/// <summary>
307+
/// Deserializes attribute data from an URL query string
308+
/// </summary>
309+
/// <param name="jsonData">Json data query string</param>
310+
/// <returns>List items with following structure: Product.Id, ProductAttribute.Id, Product_ProductAttribute_Mapping.Id, ProductVariantAttributeValue.Id</returns>
306311
public virtual List<List<int>> DeserializeQueryData(string jsonData)
307312
{
308313
if (jsonData.HasValue())
@@ -314,6 +319,14 @@ public virtual List<List<int>> DeserializeQueryData(string jsonData)
314319
}
315320
return new List<List<int>>();
316321
}
322+
323+
/// <summary>
324+
/// Serializes attribute data
325+
/// </summary>
326+
/// <param name="productId">Product identifier</param>
327+
/// <param name="attributesXml">Attribute XML string</param>
328+
/// <param name="urlEncode">Whether to URL encode</param>
329+
/// <returns>Json string with attribute data</returns>
317330
public virtual string SerializeQueryData(int productId, string attributesXml, bool urlEncode = true)
318331
{
319332
if (attributesXml.HasValue() && productId != 0)

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,21 @@ public static int[] ParseRequiredProductIds(this Product product)
322322
}
323323

324324
/// <summary>
325-
/// gets the base price
325+
/// Gets the base price
326326
/// </summary>
327327
/// <param name="product">Product</param>
328328
/// <param name="localizationService">Localization service</param>
329329
/// <param name="priceFormatter">Price formatter</param>
330330
/// <param name="priceAdjustment">Price adjustment</param>
331+
/// <param name="languageIndependent">Whether the result string should be language independent</param>
331332
/// <returns>The base price</returns>
332333
public static string GetBasePriceInfo(this Product product, ILocalizationService localizationService, IPriceFormatter priceFormatter,
333-
decimal priceAdjustment = decimal.Zero)
334+
decimal priceAdjustment = decimal.Zero, bool languageIndependent = false)
334335
{
335336
if (product == null)
336337
throw new ArgumentNullException("product");
337338

338-
if (localizationService == null)
339+
if (localizationService == null && !languageIndependent)
339340
throw new ArgumentNullException("localizationService");
340341

341342
if (product.BasePriceHasValue && product.BasePriceAmount != Decimal.Zero)
@@ -346,6 +347,11 @@ public static string GetBasePriceInfo(this Product product, ILocalizationService
346347
string basePrice = priceFormatter.FormatPrice(basePriceValue, false, false);
347348
string unit = "{0} {1}".FormatWith(product.BasePriceBaseAmount, product.BasePriceMeasureUnit);
348349

350+
if (languageIndependent)
351+
{
352+
return "{0} / {1}".FormatWith(basePrice, unit);
353+
}
354+
349355
return localizationService.GetResource("Products.BasePriceInfo").FormatWith(basePrice, unit);
350356
}
351357
return "";

src/Libraries/SmartStore.Services/Common/GenericAttributeService.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,22 @@ public virtual IList<GenericAttribute> GetAttributesForEntity(int entityId, stri
165165
});
166166
}
167167

168+
/// <summary>
169+
/// Get queryable attributes
170+
/// </summary>
171+
/// <param name="key">The key</param>
172+
/// <param name="keyGroup">The key group</param>
173+
/// <returns>Queryable attributes</returns>
174+
public virtual IQueryable<GenericAttribute> GetAttributes(string key, string keyGroup)
175+
{
176+
var query =
177+
from ga in _genericAttributeRepository.Table
178+
where ga.Key == key && ga.KeyGroup == keyGroup
179+
select ga;
180+
181+
return query;
182+
}
183+
168184
/// <summary>
169185
/// Save attribute value
170186
/// </summary>

src/Libraries/SmartStore.Services/Common/IGenericAttributeService.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using SmartStore.Core;
34
using SmartStore.Core.Domain.Common;
45

@@ -41,8 +42,16 @@ public partial interface IGenericAttributeService
4142
/// <param name="keyGroup">Key group</param>
4243
/// <returns>Get attributes</returns>
4344
IList<GenericAttribute> GetAttributesForEntity(int entityId, string keyGroup);
44-
45-
/// <summary>
45+
46+
/// <summary>
47+
/// Get queryable attributes
48+
/// </summary>
49+
/// <param name="key">The key</param>
50+
/// <param name="keyGroup">The key group</param>
51+
/// <returns>Queryable attributes</returns>
52+
IQueryable<GenericAttribute> GetAttributes(string key, string keyGroup);
53+
54+
/// <summary>
4655
/// Save attribute value
4756
/// </summary>
4857
/// <typeparam name="TPropType">Property type</typeparam>

src/Libraries/SmartStore.Services/Directory/CountryService.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ public virtual Country GetCountryById(int countryId)
136136
return _countryRepository.GetById(countryId);
137137
}
138138

139+
/// <summary>
140+
/// Gets a country by two or three letter ISO code
141+
/// </summary>
142+
/// <param name="letterIsoCode">Country two or three letter ISO code</param>
143+
/// <returns>Country</returns>
144+
public virtual Country GetCountryByTwoOrThreeLetterIsoCode(string letterIsoCode)
145+
{
146+
if (letterIsoCode.HasValue())
147+
{
148+
if (letterIsoCode.Length == 2)
149+
return GetCountryByTwoLetterIsoCode(letterIsoCode);
150+
else if (letterIsoCode.Length == 3)
151+
return GetCountryByThreeLetterIsoCode(letterIsoCode);
152+
}
153+
return null;
154+
}
155+
139156
/// <summary>
140157
/// Gets a country by two letter ISO code
141158
/// </summary>

0 commit comments

Comments
 (0)