Skip to content

Commit 95a1913

Browse files
committed
smartstore#382 Feed plugins: More options and improvements
1 parent 7b235c0 commit 95a1913

14 files changed

Lines changed: 252 additions & 88 deletions

File tree

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* (Developer) Moved _PublicControllerBase_ to SmartStore.Web.Framework
3434
* (Developer) Moved 'AdminControllerBase' to SmartStore.Web.Framework
3535
* #384 Web API: Inserting sluged recources like products require an URL record
36-
* Promotion feed plugins: Asynchronous feed creation
36+
* #382 Promotion feed plugins: Asynchronous feed creation, more options and improvements
3737

3838
###Bugfixes###
3939
* Twitter Auth: fixed _SecurityTransparent_ error

src/Libraries/SmartStore.Core/Data/IDbContext.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,21 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
8585
/// </summary>
8686
/// <returns>The count of detached entities</returns>
8787
int DetachAll();
88+
89+
/// <summary>
90+
/// Change the state of an entity object
91+
/// </summary>
92+
/// <typeparam name="TEntity">Type of entity</typeparam>
93+
/// <param name="entity">The entity instance</param>
94+
/// <param name="newState">The new state</param>
95+
void ChangeState<TEntity>(TEntity entity, System.Data.Entity.EntityState newState);
96+
97+
/// <summary>
98+
/// Changes the object state to unchanged
99+
/// </summary>
100+
/// <typeparam name="TEntity">Type of entity</typeparam>
101+
/// <param name="entity">The entity instance</param>
102+
/// <returns>true on success, false on failure</returns>
103+
bool SetToUnchanged<TEntity>(TEntity entity);
88104
}
89105
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.ComponentModel;
77
using System.Web.Routing;
88
using SmartStore.Core;
9+
using System.Globalization;
910

1011
namespace SmartStore
1112
{
@@ -138,5 +139,16 @@ public static void Grow(this StringBuilder sb, string grow, string delimiter)
138139
sb.AppendFormat("{0}{1}", delimiter, grow);
139140
}
140141
}
142+
143+
/// <summary>
144+
/// Rounds and formats a decimal culture invariant
145+
/// </summary>
146+
/// <param name="value">The decimal</param>
147+
/// <param name="decimals">Rounding decimal number</param>
148+
/// <returns>Formated value</returns>
149+
public static string FormatInvariant(this decimal value, int decimals = 2)
150+
{
151+
return Math.Round(value, decimals).ToString("0.00", CultureInfo.InvariantCulture);
152+
}
141153
}
142154
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,6 @@ public static string RemoveEncloser(this string value, string start, string end,
712712
return value;
713713
}
714714

715-
// codehint: sm-add (begin)
716-
717715
/// <summary>Debug.WriteLine</summary>
718716
/// <remarks>codehint: sm-add</remarks>
719717
[DebuggerStepThrough]
@@ -999,7 +997,19 @@ public static string RemoveInvalidXmlChars(this string s)
999997
return Regex.Replace(s, @"[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]", "", RegexOptions.Compiled);
1000998
}
1001999

1002-
// codehint: sm-add (end)
1000+
[DebuggerStepThrough]
1001+
public static string ReplaceCsvChars(this string s)
1002+
{
1003+
if (s.HasValue())
1004+
{
1005+
s = s.Replace(';', ',');
1006+
s = s.Replace('\r', ' ');
1007+
s = s.Replace('\n', ' ');
1008+
return s.Replace("'", "");
1009+
}
1010+
return "";
1011+
}
1012+
10031013
#endregion
10041014

10051015
#region Helper

src/Libraries/SmartStore.Data/ObjectContextBase.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,25 @@ public int DetachAll()
519519
return attachedEntities.Count;
520520
}
521521

522+
public void ChangeState<TEntity>(TEntity entity, System.Data.Entity.EntityState newState)
523+
{
524+
((IObjectContextAdapter)this).ObjectContext.ObjectStateManager.ChangeObjectState(entity, newState);
525+
}
526+
527+
public bool SetToUnchanged<TEntity>(TEntity entity)
528+
{
529+
try
530+
{
531+
ChangeState<TEntity>(entity, System.Data.Entity.EntityState.Unchanged);
532+
return true;
533+
}
534+
catch (Exception exc)
535+
{
536+
exc.Dump();
537+
return false;
538+
}
539+
}
540+
522541
private string FormatValidationExceptionMessage(IEnumerable<DbEntityValidationResult> results)
523542
{
524543
var sb = new StringBuilder();

src/Plugins/Feed.Froogle/Description.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FriendlyName: Google Merchant Center (GMC)
22
SystemName: PromotionFeed.Froogle
3-
Version: 2.2
3+
Version: 2.21
44
MinAppVersion: 2.0.0
55
Author: SmartStore AG
66
DisplayOrder: 1

src/Plugins/Feed.Froogle/FroogleFeedPlugin.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public FroogleFeedPlugin(
2323
GoogleProductObjectContext objectContext,
2424
ILocalizationService localizationService)
2525
{
26-
this._googleService = googleService;
27-
this._settingService = settingService;
28-
this._objectContext = objectContext;
29-
this._localizationService = localizationService;
26+
_googleService = googleService;
27+
_settingService = settingService;
28+
_objectContext = objectContext;
29+
_localizationService = localizationService;
3030
}
3131

3232
/// <summary>
@@ -69,7 +69,7 @@ public override void Uninstall()
6969

7070
_settingService.DeleteSetting<FroogleSettings>();
7171

72-
_localizationService.DeleteLocaleStringResources(this.PluginDescriptor.ResourceRootKey);
72+
_localizationService.DeletePluginStringResources(this.PluginDescriptor);
7373

7474
var migrator = new DbMigrator(new Configuration());
7575
migrator.Update(DbMigrator.InitialDatabase);

src/Plugins/Feed.Froogle/Localization/resources.de-de.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,16 @@
266266
<LocaleResource Name="ExportBasePrice.Hint">
267267
<Value>Aktivieren Sie diese Option, wenn Sie denGrundpreis des Produkt exportieren möchten.</Value>
268268
</LocaleResource>
269+
<LocaleResource Name="ConvertNetToGrossPrices">
270+
<Value>Netto- in Bruttopreise umrechnen</Value>
271+
</LocaleResource>
272+
<LocaleResource Name="ConvertNetToGrossPrices.Hint">
273+
<Value>Legt fest, dass Netto- in Bruttopreise umgerechnet werden sollen.</Value>
274+
</LocaleResource>
275+
<LocaleResource Name="LanguageId">
276+
<Value>Sprache</Value>
277+
</LocaleResource>
278+
<LocaleResource Name="LanguageId.Hint">
279+
<Value>Legt die Sprache fest, in der sprachabhängige Werte (z.B. der Produktname) exportiert werden sollen.</Value>
280+
</LocaleResource>
269281
</Language>

src/Plugins/Feed.Froogle/Localization/resources.en-us.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,16 @@
266266
<LocaleResource Name="ExportBasePrice.Hint">
267267
<Value>Activate this option if you want to export the base price of the product.</Value>
268268
</LocaleResource>
269+
<LocaleResource Name="ConvertNetToGrossPrices">
270+
<Value>Convert net into gross prices</Value>
271+
</LocaleResource>
272+
<LocaleResource Name="ConvertNetToGrossPrices.Hint">
273+
<Value>Determines to convert net into gross prices.</Value>
274+
</LocaleResource>
275+
<LocaleResource Name="LanguageId">
276+
<Value>Language</Value>
277+
</LocaleResource>
278+
<LocaleResource Name="LanguageId.Hint">
279+
<Value>Determines which language to use to export language dependent values (for instance the product name).</Value>
280+
</LocaleResource>
269281
</Language>

src/Plugins/Feed.Froogle/Models/FeedFroogleModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public string AvailableGoogleCategoriesAsJson
106106
[SmartResourceDisplayName("Plugins.Feed.Froogle.ExportBasePrice")]
107107
public bool ExportBasePrice { get; set; }
108108

109+
[SmartResourceDisplayName("Plugins.Feed.Froogle.ConvertNetToGrossPrices")]
110+
public bool ConvertNetToGrossPrices { get; set; }
111+
112+
[SmartResourceDisplayName("Plugins.Feed.Froogle.LanguageId")]
113+
public int LanguageId { get; set; }
114+
109115
public void Copy(FroogleSettings settings, bool fromSettings)
110116
{
111117
if (fromSettings)
@@ -137,6 +143,8 @@ public void Copy(FroogleSettings settings, bool fromSettings)
137143
ExpirationDays = settings.ExpirationDays;
138144
ExportShipping = settings.ExportShipping;
139145
ExportBasePrice = settings.ExportBasePrice;
146+
ConvertNetToGrossPrices = settings.ConvertNetToGrossPrices;
147+
LanguageId = settings.LanguageId;
140148
}
141149
else
142150
{
@@ -167,6 +175,8 @@ public void Copy(FroogleSettings settings, bool fromSettings)
167175
settings.ExpirationDays = ExpirationDays;
168176
settings.ExportShipping = ExportShipping;
169177
settings.ExportBasePrice = ExportBasePrice;
178+
settings.ConvertNetToGrossPrices = ConvertNetToGrossPrices;
179+
settings.LanguageId = LanguageId;
170180
}
171181
}
172182
}

0 commit comments

Comments
 (0)