Skip to content

Commit

Permalink
Fixed some installation issues with url records
Browse files Browse the repository at this point in the history
  • Loading branch information
muratcakir committed May 25, 2018
1 parent b8bfd72 commit 4becebe
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 115 deletions.
77 changes: 65 additions & 12 deletions src/Libraries/SmartStore.Data/Setup/SeedData/InvariantSeedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Text;
using SmartStore.Core;
using SmartStore.Core.Configuration;
using SmartStore.Core.Domain;
using SmartStore.Core.Domain.Blogs;
Expand Down Expand Up @@ -47,10 +48,10 @@ protected InvariantSeedData()

public void Initialize(SmartObjectContext context)
{
this._ctx = context;
_ctx = context;

this._sampleImagesPath = CommonHelper.MapPath("~/App_Data/Samples/");
this._sampleDownloadsPath = CommonHelper.MapPath("~/App_Data/Samples/");
_sampleImagesPath = CommonHelper.MapPath("~/App_Data/Samples/");
_sampleDownloadsPath = CommonHelper.MapPath("~/App_Data/Samples/");
}

#region Mandatory data creators
Expand Down Expand Up @@ -3934,7 +3935,6 @@ public IList<Topic> Topics()
Body = "<p>Put your shipping &amp; returns information here. You can edit this in the admin site.</p>"
},

//codehint: sm-add begin
new Topic
{
SystemName = "Imprint",
Expand Down Expand Up @@ -14790,6 +14790,10 @@ protected virtual void Alter(IList<ProductBundleItem> entities)
{
}

protected virtual void Alter(UrlRecord entity)
{
}

#endregion Alterations

#endregion Sample data creators
Expand Down Expand Up @@ -14820,6 +14824,53 @@ protected string SampleDownloadsPath
}
}

public virtual UrlRecord CreateUrlRecordFor<T>(T entity) where T : BaseEntity, ISlugSupported, new()
{
var name = "";
var languageId = 0;

switch (entity)
{
case Category x:
name = x.Name;
break;
case Manufacturer x:
name = x.Name;
break;
case Product x:
name = x.Name;
break;
case BlogPost x:
name = x.Title;
languageId = x.LanguageId;
break;
case NewsItem x:
name = x.Title;
languageId = x.LanguageId;
break;
case Topic x:
name = SeoHelper.GetSeName(x.SystemName, true, false).Truncate(400);
break;
}

if (name.HasValue())
{
var result = new UrlRecord
{
EntityId = entity.Id,
EntityName = entity.GetUnproxiedType().Name,
LanguageId = languageId,
Slug = name,
IsActive = true
};

this.Alter(result);
return result;
}

return null;
}

protected Picture CreatePicture(byte[] pictureBinary, string mimeType, string seoFilename)
{
mimeType = mimeType.EmptyNull().Truncate(20);
Expand Down Expand Up @@ -14852,14 +14903,16 @@ protected Currency CreateCurrency(string locale, decimal rate = 1M, string forma
info = new RegionInfo(locale);
if (info != null)
{
currency = new Currency();
currency.DisplayLocale = locale;
currency.Name = info.CurrencyNativeName;
currency.CurrencyCode = info.ISOCurrencySymbol;
currency.Rate = rate;
currency.CustomFormatting = formatting;
currency.Published = published;
currency.DisplayOrder = order;
currency = new Currency
{
DisplayLocale = locale,
Name = info.CurrencyNativeName,
CurrencyCode = info.ISOCurrencySymbol,
Rate = rate,
CustomFormatting = formatting,
Published = published,
DisplayOrder = order
};
}
}
catch
Expand Down
4 changes: 4 additions & 0 deletions src/Libraries/SmartStore.Data/SmartStore.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -42,6 +43,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'EFMigrations|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -51,6 +53,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PluginDev|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -60,6 +63,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=4.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
Expand Down
4 changes: 1 addition & 3 deletions src/Libraries/SmartStore.Services/Seo/SeoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,10 @@ public static string ValidateSeName<T>(this T entity,
int i = 2;
var tempSeName = seName;

extraSlugLookup = extraSlugLookup ?? ((s) => null);

while (true)
{
// check whether such slug already exists (and that it's not the current entity)
var urlRecord = urlRecordService.GetBySlug(tempSeName) ?? extraSlugLookup(tempSeName);
var urlRecord = urlRecordService.GetBySlug(tempSeName) ?? extraSlugLookup?.Invoke(tempSeName);
var reserved1 = urlRecord != null && !(urlRecord.EntityId == entity.Id && urlRecord.EntityName.Equals(entityName, StringComparison.InvariantCultureIgnoreCase));

if (!reserved1 && urlRecord != null && languageId.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1928,10 +1928,45 @@ 44135 Dortmund<br>
x. Title = "Zahlungsarten";
x.Body = "<p><p>Fügen Sie Informationen zu Zahlungsarten hier ein. Sie können diese in der Admin-Seite zu bearbeiten.</p>";
});

}

protected override void Alter(IList<ISettings> settings)
protected override void Alter(UrlRecord entity)
{
base.Alter(entity);

if (entity.EntityName == "Topic")
{
switch (entity.Slug)
{
case "aboutus":
entity.Slug = "ueber-uns";
break;
case "conditionsofuse":
entity.Slug = "agb";
break;
case "contactus":
entity.Slug = "kontakt";
break;
case "privacyinfo":
entity.Slug = "datenschutz";
break;
case "shippinginfo":
entity.Slug = "versand-und-rueckgabe";
break;
case "imprint":
entity.Slug = "impressum";
break;
case "disclaimer":
entity.Slug = "widerrufsrecht";
break;
case "paymentinfo":
entity.Slug = "zahlungsarten";
break;
}
}
}

protected override void Alter(IList<ISettings> settings)
{
base.Alter(settings);

Expand Down Expand Up @@ -4101,5 +4136,5 @@ protected override void Alter(IList<PollAnswer> entities)
x.Name = "Einmal im Monat";
});
}
}
}
}
Loading

0 comments on commit 4becebe

Please sign in to comment.