Register Shopping cart (0)
You have no items in your shopping cart.
Free nopCommerce Hosting

Blog posts tagged with 'migrations'

Migrating Old (Existing) URLs to nopCommerce URLs

Being a popular e-commerce platform, it is very common for store owners to want to migrate to nopCommerce for its powerful features.

One common problem developers face is to migrate old, existing links (from some other e-commerce platforms) to new links (nopCommerce). Especially for old sites which are already getting tons of traffics and are having very good SEO rankings, it is very important to make sure the old URLs are 301-redirected to new nopCommerce URLs.

If it's static URLs (e.g. those for content pages), you can already use IIS URL Rewrite to do the migration manually. But the problem arises when it comes to product and category urls. Because the URLs are dynamic (and there are tons of those URLs), it is usually impractical to manually add URL Rewrite entries one-by-one.

Take the following URLs for example:

  • http://oldsite.com/product-slug-one-p1234.htm
  • http://oldsite.com/product-slug-two-p4567.htm
  • http://oldsite.com/category-slug-one-c12.htm
  • http://oldsite.com/category-slug-two-c34.htm

If you look at the URLs, they are pretty dynamic. Product URLs follow a pattern of {product-slug}-p{product-id}.htm. Category links also follow a similar pattern.

And to make the problem worse (which happens very often), old product IDs (and category IDs) do not correspond to new product IDs. That means in old system, product ID 1234 is product ID 4321 in new system.

So the question now is - how can we make sure old URLs, such as http://oldsite.com/product-slug-one-p1234.htm, will be 301-redirected to new nopCommerce URLs, such as http://nopcommercesite.com/product-one-new-slug?

Using Entity Framework (EF) Code-First Migrations in nopCommerce for Fast Customizations

I've seen a lot of nopCommerce forums users asking how they can use Entity Framework (EF) Code-First Migrations to customize nopCommerce, add new fields and entites to the core. I actually use a lot of EF Migrations myself when doing nopCommerce customization projects, and I must say it helps a lot in the development.

Today, I'll share with you how you can do that in nopCommerce project! I'll be using nopCommerce 3.20 as an example, but you can easily apply the concept to other vesions!

Setting Up EF Migrations in nopCommerce Solution

The first thing you want to do is to enable migrations in your nopCommerce solution. So fire up nopCommerce in Visual Studio, look at Nop.Web project, and open Web.config. You need to add a connection string to your development database. Note that adding the connection string in Web.config doesn't affect how nopCommerce works, since nopCommerce doesn't look for connection string in Web.config.

EF Migrations in nopCommerce - Setup Web.config

Hello, welcome to pro nopCommerce!

I am Woon Cherk, an nop mvp; and this blog is the place where I share my experiences developing nopCommerce themes and nopCommerce plugins. I also give out free nopCommerce plugins and free nopCommerce themes from time to time, make sure you subscribe to our e-mail newsletter to get updates and freebies! Click here to read more about me.