Introduction
In this tip, we will go over the steps for adding a store logo in nopCommerce. The default solution comes with a free theme that also includes a default logo but when any user is launching a website based on nopCommerce, the store logo needs to be changed in order to personalize the store site with a brand logo.
Background
nopCommerce is an open source ecommerce software that is based on ASP.NET (MVC) and it contains both a catalog frontend and an administration tool backend. nopCommerce is a fully customizable shopping cart. (Source: www.nopcommerce.com)
nopCommerce is open-source, the source code is available free for download: CLICK HERE
Steps
- Make sure you have the image file of your new logo. For this example, we will use "NewStoreLogoImage.jpg" file.
- Save the new logo in this location: Custom Theme Folder (or DefaultClean ) / Content / images /
- In your web files, go to this location: Views / Shared / Header.cshtml
Open the "Header.cshtml" file and you will find this code at the top:
@using Nop.Core
@using Nop.Core.Infrastructure
@using Nop.Services.Localization
@using Nop.Web.Framework.Themes
@{
//logo path
var currentThemeName = EngineContext.Current.Resolve<IThemeContext>().WorkingThemeName;
var logoPath = "~/Themes/" + currentThemeName + "/Content/images/logo.png";
//store name
var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
}
- For adding your logo, you need to change file name like this:
var logoPath = "~/Themes/" + currentThemeName +
"/Content/images/NewStoreLogoImage.jpg";
So, the code will be:
@using Nop.Core
@using Nop.Core.Infrastructure
@using Nop.Services.Localization
@using Nop.Web.Framework.Themes
@{
//logo path
var currentThemeName = EngineContext.Current.Resolve<IThemeContext>().WorkingThemeName;
var logoPath = "~/Themes/" +
currentThemeName + "/Content/images/NewStoreLogoImage.jpg";
//store name
var storeName =
EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
}
That is all - Make sure to save changes and view the public store site. You should be able to see the new logo:
Tip
If you are interested in knowing how the logo is being used in the web file, look into the "Header.cshtml" code and you will see this:
<div class="header-lower">
<div class="header-logo">
<a href="@Url.RouteUrl("HomePage")">
<img title="" alt="@storeName"
src="@Url.Content(logoPath)">
</a>
</div>
<div class="search-box">
@Html.Action("SearchBox", "Catalog")
</div>
</div>
A Few Things To Keep in Mind
- The default dimensions of the logo is: 310px (width) X 60px (height)
- If you do not want to change anything in the code, you can replace the default logo with your new logo image file (just make the dimensions match)
- Version used for this article: nopCommerce 3.60
Founder of Striving Programmers Online Community: http://www.strivingprogrammers.com
I am a programmer / web developer / software developer / graphic designer / database administrator.
Working with .NET Frameworks 2.0/3.5/4.0, MS SQL Server 2000/2005/2008, Oracle 8i/9i/10G, ASP.NET, C#.NET, VB.NET, ASP.NET AJAX, ASP.NET MVC, Web Services, JQuery, HTML, CSS, JavaScript and other programming languages .
Proficient in designing tools: Adobe Photoshop & Adobe Illustrator