Magelia WebStore

  • Summary

How to use Magelia WebStore in a Visual Studio project

Overview: NuGet package

Information: To configure the settings of your environment, please refer to the Installation Guide (available soon).

Download the code sample of this tutorial:
How to use Magelia WebStore in a Visual Studio project - ZIP - 20.3 mo

With Visual Studio 2010, we saw the arrival of a package manager named NuGet. This one is open source and is under the CodePlex license: http://nuget.codeplex.com/. It allows users to obtain different public packages by internet.

In order to facilitate the e-commerce application integration, the Magelia WebStore software is available with a .NET client. The client is composed of a unique assembly (dll) named Magelia.WebStore.Client.dll. In the following section, we are going to see how to add this package to your Visual Studio project.

For more information on the client Magelia WebStore client library and its utilization, please refer to the section How to Use the WebStoreClient Class.

NuGet is installed by default with Visual Studio 2012.
To install it with Visual Studio 2010, you need to use the extensions manager. To do so, in Visual Studio, go to Tools > Extension Manager:

To install it with Visual Studio 2010

Then in Online Gallery, look for NuGet.

You will see pop-up NuGet Package Manager. Then click on Download. You must then accept the Terms of Use. You may be asked to restart Visual Studio.

You will see pop-up NuGet Package Manager. Then click on Download. You must then accept the Terms of Use. You may be asked to restart Visual Studio.

How to Add the NuGet Package in a Visual Studio Project

To install the Magelia WebStore client package via NuGet, you have two possibilities, either using the NuGet package management graphical interface, or using the console: Package Manager Console.

Installation via the NuGet graphical interface:

To install the NuGet package via the graphical interface, right click on your project and then select Manage NuGet Packages

To install the NuGet package via the graphical interface

Next look up the package desired, here Magelia WebStore client library. Then Install.

Next look up the package desired

It will download and install the necessary and relevant packages.

It will download and install the necessary and relevant packages.

Accept the different contracts and corresponding license terms by clicking on I Accept.

Accept the different contracts and corresponding license terms by clicking on I Accept.

The installation is going to change the project to make reference to the libraries necessary for using Magelia WebStore client library.

When updates are available, they will appear in the Updates tab. You can then execute these with ease by selecting the update and clicking on Update.

Installation via the NuGet console:

To install the package Magelia WebStore client library via the console, you will need to go to Tools > Library Package Manager, then Package Manager Console.

To install the package Magelia WebStore client library via the console

Here are the main commands useable in the NuGet console:
Install-Package magelia.webstore.client: Install the magelia package
Uninstall-Package magelia.webstore.client: Uninstall the magelia package
Get-Package –updates: List updates for the project
Update-Package magelia.webstore.client: Update the magelia package

Other commands that may also be useful:
get-help Nuget: Displays the NuGet help
get-Package –listavailable: Lists the packages available by download (rather long)
get-Package -listavailable -filter magelia: Lists the packages that contain magelia

Once the NuGet console is launched, simply enter the following command: PM> install-package Magelia.Webstore.Client to be able to use the Magelia WebStore services directly in your application.

How to configure the WebStoreClient settings:

Each method of Magelia web services requires information that is common to entirety of the e-commerce application. To avoid having to specify these setting for each service method, the client will obtain these settings in the application’s configuration file.

During installation of the WebStore client package via NuGet, a configuration file is added or updated, depending on the case, to your project. This file contains the default configuration of the Magelia client.

Below is an example of a configuration generated while adding the package Magelia Webstore client library:

<configuration>
  <configSections>
    <sectionGroup name="magelia">
      <section name="webStoreClient"
               type="Magelia.WebStore.Configuration.WebStoreClientConfiguration, Magelia.WebStore.Client"
               requirePermission="false" />
    </sectionGroup>
  </configSections>
  <magelia>
    <webStoreClient servicePath="http://localhost/admin/services/"
                    storeId="DCAFD470-B122-11E0-A00B-0800200C9A66" />
  </magelia>
</configuration>

Initially, we can observe the declaration of the configuration section via the following XML code:

<configuration>
  <configSections>
    <sectionGroup name="magelia">
      <section name="webStoreClient"
               type="Magelia.WebStore.Configuration.WebStoreClientConfiguration, Magelia.WebStore.Client"
               requirePermission="false" />
    </sectionGroup>
  </configSections>
</configuration>

Next, we observe the section magelia, which allows you to define the settings relative to your store:

<configuration>
  <magelia>
    <!-- see  to get help on how to modify theses value -->
    <webStoreClient servicePath="http://localhost/admin/services/"
                    storeId="DCAFD470-B122-11E0-A00B-0800200C9A66" />
  </magelia>
</configuration>

2 parameters need to be given values:

img

You can find the storied of your instance of Magelia WebStore, via the administration interface, by visiting the section Sellers - Stores, then Store settings:

You can find the storied of your instance of Magelia WebStore

In the same fashion, the base address of your Magelia services is found in the section Platform settings, then in Tier Application, generally in the form http://URL/Admin/Services/

In the same fashion

How to set advanced parameters for the WCF services

The Magelia WebStore client supplies an ensemble of WCF services allowing you to easily access and examine your instance of Magelia WebStore. There are three services provided:

Magelia.WebStore.Client.StoreServiceClient: provides the methods allowing you to access and manage your storefront.
Magelia.WebStore.Client.CatalogServiceClient: provides the methods allowing you to access your catalogs, categories, products, etc.
Magelia.WebStore.Client.CustomerServiceClient: provides the methods allowing you to manage your users.
Magelia.WebStore.Client.AdministrationServiceClient: provides methods which allow management of the Magelia WebStore platform.
Magelia.WebStore.Client.HeartBeatServiceClient: provides the methods allowing you to access the Magelia WebStore platform status.

By default, the Magelia WebStore client encapsulates the entire WCF configuration of these services. If you wish to personalize this configuration, you may use the following attributes at the level of the section webstoreClient of your configuration file:

img

Warning! It is not possible to personalize the configuration for the Catalog part. Contrary to the other WCF services, the Catalog part is exposed via an OData service.
For more information, please refer to the section How to access catalog information.

These different attributes are related to the configuration of the WCF classic endpoints. The example below shows how to use these attributes in coordination with the WCF configuration:

<configuration>
  <configSections>
    <sectionGroup name="magelia">
      <section name="webStoreClient"
               type="Magelia.WebStore.Configuration.WebStoreClientConfiguration, Magelia.WebStore.Client"
               requirePermission="false" />
    </sectionGroup>
  </configSections>
  <magelia>
    <webStoreClient
      storeId="DCAFD470-B122-11E0-A00B-0800200C9A66"
      servicePath="http://YourPath/admin/services/"
      storeServiceEndPointName="StoreEndPoint"
    />
  </magelia>
  <system.serviceModel>
    <client>
      <endpoint name="StoreEndPoint"
                binding="basicHttpBinding" bindingConfiguration="StoreBinding"
                contract="Magelia.WebStore.Services.Contract.IStore"  />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding name="StoreBinding" maxReceivedMessageSize="10485760" />
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

As you see in the previous example, the configuration applied by default uses the binding basicHttpBinding with the following configuration:

<binding maxreceivedmessagesize="2147483648">
  <readerQuotas maxStringContentLength="10485760"/>
</binding>

It is thus possible to extend the configuration of the WCF bindings. For example, in order to increase/decrease the size of exchanged messages. For this you will need to edit your project’s configuration file again.

Here is an example of an extended configuration file:

<configuration>
  <configSections>
    <sectionGroup name="magelia">
      <section name="webStoreClient"
               type="Magelia.WebStore.Configuration.WebStoreClientConfiguration, Magelia.WebStore.Client"
               requirePermission="false" />
    </sectionGroup>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <magelia>
    <webStoreClient
      storeId="DCAFD470-B122-11E0-A00B-0800200C9A66"
      servicePath="http://YourPath/admin/services/"
      storeServiceEndPointName="StoreEndPoint"
    />
  </magelia>
  <system.serviceModel>
    <client>
      <endpoint name="StoreEndPoint"
                binding="basicHttpBinding" bindingConfiguration="StoreBinding"
                contract="Magelia.WebStore.Services.Contract.IStore"  />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding name="StoreBinding" maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600">
          <readerQuotas maxStringContentLength="10485760" />
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

The following link allows you to find out more about endpoint configuration: Client Configuration

By installing Magelia WebStore client library via the NuGet package, you will also notice the addition of a section Membership and Profile in your configuration file that are not covered in this section.
For more information on using Membership and Profile provider, see the section How to use the membership and profile provider.

Download the code sample of this tutorial:
How to use Magelia WebStore in a Visual Studio project - ZIP - 20.3 mo