Support and Docs

3 Topics
Last post 11 November 2014 By Nadja Kristiansen
1 Topics
Last post 20 March 2014 By Carsten E. Madsen
0 Topics
Last post N/A By N/A
0 Topics
Last post N/A By N/A
1 Topics
Last post 02 April 2014 By Carsten E. Madsen

Product URL migration from one eSeller Cloud webshop to another

  • 15/01/2016

This article will show you how to migrate product URLs from one eSeller Cloud webshop to another. The typical use case is that an existing eSeller Cloud webshop owner gets a new eSeller Cloud webshop to replace the existing one, and wishes to create 301 redirects from the old product URLs to the new product URLs. This guide presupposes that products have already been created in the new eSeller Cloud webshop, and that the external product IDs used on both webshops are identical.

By exporting XML files containing ext. product IDs and URLs for all products from both the new and the old eSeller Cloud webshop, you are able to generate a CSV document containing 301 redirects from the old product URLs to the new product URLs – ready to import to the new eSeller Cloud webshop using the shop administration import wizard.

We suggest reading the documentation on 301 redirects in eSeller Cloud.

Under the Resources section at the bottom of this article you find the XML files, XSL file and the transformed CSV file used in this example.

Contents

  • Why are redirects necessary?
  • How to create a CSV document containing the 301 redirects

    Why are redirects necessary?

    In eSeller Cloud product URLs are generated automatically based on the product name and product number (sometimes referred to as “internal ID”). This product number is a unique ID assigned to all products upon creation, and it cannot be changed.

    By “product URLs” is meant URLs that represent product details pages (contains “/pi/”) – e.g. /pi/my-product_2200695_.aspx; “my-product” is the product name and “2200695” is the product number.

    When this same product is created in a new eSeller Cloud webshop, the product number of the product will be different, and hence the product URL will be different – e.g. /pi/my-product_2510753_.aspx. In order for the old product URL to redirect to the new product URL it is necessary to create a 301 redirect that redirect the old product URL to the new product URL – otherwise the old URL will simply lead to a 404 page.

    As long as the ext. product IDs are identical on both the old and the new eSeller Cloud webshop, it is possible to map the old product URL with the new product URL, thus creating 301 redirects from the old URLs to the new URLs.

    How to create a CSV document containing the 301 redirects

    The following section describes how to generate a CSV document containing 301 redirects from the old product URLs to the new product URLs.

    Exporting the XML files containing new and old product URLs

    Export the product URLs from the old eSeller Cloud webshop
    - In the shop administration of the old eSeller Cloud webshop, go to Integration > Import/Export > Export guide
    - On step 2, select “Product” as the data type for export
    - On step 3, select the columns “ExtProductId” and “URL” for export
    - On step 5, select XML as the output file type

    Export the product URLs from the new eSeller Cloud webshop
    - In the shop administration of the new eSeller Cloud webshop, go to Integration > Import/Export > Export guide
    - On step 2, select “Product” as the data type for export
    - On step 3, select the columns “ExtProductId” and “URL” for export
    - On step 5, select XML as the output file type

    Preparing the exported XML files for transformation

    In order for the XSL file to work in this is example it is necessary that the following changes are made to the exported XML files:
    - Old URLs file: Change the <exportdata> element to <OldUrls> for the XML document containing the old URLs
    - New URLs file: Change the <exportdata> element to <NewUrls> for the document containing the new URLs
    - Both files: Remove all other elements so that <export> becomes the root element of both files.

    Example XML file:

    <?xml version="1.0" encoding="utf-8" ?>
    <export object="Product">
        <NewUrls>
            <Product>
                <ExtProductId>xwmd0134</ExtProductId>
                <URL>/pi/my-product1_2026382_.aspx</URL>
            </Product>
            <Product>
                <ExtProductId>2027338</ExtProductId>
                <URL>/pi/my-product2_2027338_.aspx</URL>
            </Product>
            <Product>
                <ExtProductId>xwmd0135</ExtProductId>
                <URL>/pi/my-product3_2088905_.aspx</URL>
            </Product>
        </NewUrls>
    </export>
    
    Binding the transformation file to the XML file containing the old URLs

    In the XML document containing the old URLs, add the following declaration just below the XML declaration:

    <xml-stylesheet type="text/xsl" href="transformUrls.xsl" ?>
    This line binds the document containing the old URLs with the XSL file responsible for transforming the XML files.
    - See the example XML file "OLD.xml" under the Resources section at the bottom of this article.

    Ensure proper file naming and location

    It is important that the file names of your XML files and XSL file corresponds with what references are made in the files.

    The XML documents containing the old URLs are bound to the XSL file via the declaration described above – note that this statement refers to the file “transformUrls.xsl” and assumes that the XSL file is located in the same folder as the XML file containing the old URLs. It is important that your XSL file is named and located as specified in this declaration.

    As part of the transformation, it iterates through the document containing the new URLs. In order for the correct file to used, you must ensure that the correct file name and location is specified in the XSL file.

    <xsl:for-each select="document('NEW.xml')">
    In this example the XML file containing the new URLs is named “NEW.xml” and is located in the same folder as the XSL file.
    - See the example XSL file "transformUrls.xsl" under the Resources section at the bottom of this article.

    Updating the old URLs

    Besides the “fromUrl” and “NewUrl”, each redirect has additional properties such as IsRegularExpression, PassAnyQueryParameter and Priority. In this example the values of these properties are hard coded in the XSL file and can be altered by altering the XSL file. Alternatively, a fixed value for these properties (except for Priority) can be selected on step 5 of the import wizard.

    Regular expression

    Since the exported product URLs are always exclusive menu ID (e.g. >/pi/my-product2_2027338_.aspx rather than >/pi/my-product2_2027338_5477.aspx, where “5477” is the menu ID), it is necessary to create the redirects as regular expressions that match product URLs containing the menu ID – otherwise these URLs will lead to 404 pages.

    This is done by ensuring that the IsRegularExpression and (and optinally PassAnyQueryParameters) properties are True for all redirects. Moreover, it is necessary to add some regular expression to the old URLs (FromUrl) that enables the redirects to match product URLs containing a menu ID.

    Before transforming the files, the XML document containing the old URLs should be changed so that all of the URLs become valid regular expressions, matching product URLs including menu ID:
    - Search and replace all forward slashes (“/”) in the old URLs with escaped slashes (“\/”) – because forward slash is a reserved regular expression character, it is necessary to escape this character in the URLs.
    - Search and replace “.aspx” with “.*” (regular expression for matching any character between zero and unlimited times) in the old URLs – this will enable the regular expression to match the URLs including the menu ID.

    Example:
    Original old URL from exported file: /pi/my-product2_2027338_.aspx
    Old URL updated with the changes above: \/pi\/my-product2_2027338_.*
    This regular expression will match URLs such as /pi/my-product2_2027338_5477.aspx (including menu ID).

    Encoding

    Special consideration should be made with URLs that contain special characters (e.g. æ, ø, ä, ü) – such characters may need encoding or alternatively regular expression wildcard replacement (e.g. /pi/påskeæg_1254348_5150.aspx >> \/pi\/p.ske.g_1254348_5150.*)

    Performing the transformation

    The actual transformation can be done using special software that supports XSL transformation, online transformation tools or simply by opening the XML document referring to the XSL file in a browser, that support XSL transformation – e.g. Mozilla Firefox. In this example we will be using a Firefox browser.

    Right-click the XML file containing the old URLs (if this is the file that contains the style sheet declaration) and open the file with Firefox.

    Now the browser will display the result of the transformation, and you simply copy and paste the transformed data to a text editing application (e.g. Notepad++) and save it with the .csv file extension.

    Please look through the file to ensure that the result is what was expected.

    In this example the XSL file transformUrls.xsl is responsible for the transformation of the XML files. You can find the XSL file used in this example under the Resources section below. Note that the XSL file is only an example file – no guarantees are made when using it as is.

    In this example the CSV file that is created by transforming the XML files containing the product URLs contains the columns FromUrl (old URL), ToUrl (new URL), IsRegex, PassQueryParams and Priority. By altering the XSL file, you can change how the transformation is done, as well as what columns to include in the CSV file. The result of transforming the XML files is also available from the Resources section below.

    Importing the 301 redirects file

    This transformed CSV file can be imported directly to the new eSeller Cloud webshop, which then creates the proper 301 redirects.

    We recommend beginning by importing only a part of the 301 redirects, thus ensuring that the result is what is expected before importing all redirects (possibly several thousands).

    The file is imported via the shop administration. When logged in as administrator of the new webshop, go to Integration > Import/Export > Import guide.
    - On step 2, upload the newly created CSV file
    - On step 3, ensure that data looks correct in the “example window”
    - On step 4, select “RedirectMapping” as the data type for import
    - On step 5, map the columns to the appropriate columns of the CSV file
    - Import the file and check, that the redirects are working correctly (NOTE that caching may prevent the redirects from being affective immediately).

    RESOURCES

    • OLD.xml - XML file containing the old product URLs
    • NEW.xml - XML file containing the new product URLs
    • transformUrls.xsl - XSL transformation file responsible for transforming the XML files into a CSV file
    • transformedFile.csv - The CSV file containing the 301 redirects resulting from the transformation