Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • nug 11 posts 33 karma points
    Aug 19, 2012 @ 09:54
    nug
    0

    Nicer Urls

    Hi guys,

    Apologies if this has already been answered.  But I couldn't find it!

    How do I remove the "/c-23" & "c-23/c-71/p-106", etc when viewing product pages?

    I have Ucommerce 2.6.1 on Umbraco 4.7.1.

    Cheers

     

     

  • Michael Hyldsgaard 64 posts 124 karma points
    Aug 19, 2012 @ 10:20
    Michael Hyldsgaard
    0

    I'm pretty sure that you can't... 

    uCommerce relies on these parameters to fetch the correct product and product catalog.

    You might be able to do some advanced url rewriting but that would require unique catalog and product names.

    /Michael

  • nug 11 posts 33 karma points
    Aug 19, 2012 @ 10:43
    nug
    0

    Thanks Michael.  But I was hoping that would not be the answer!

    I had a look at some of the links here http://www.ucommerce.dk/en/customers.aspx and they seem to have been able to achieve it?

  • Michael Hyldsgaard 64 posts 124 karma points
    Aug 19, 2012 @ 10:53
    Michael Hyldsgaard
    0

    You can take a look at the URL rewriting rules in /config/UrlRewriting.config file.

    For example the default rule for products is:

    <add name="DefaultProductRewrite" virtualUrl="(.*)/c-([0-9]+)/p-([0-9]+)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/shop/product.aspx?catalog=$2&amp;product=$3" ignoreCase="true" xmlns="" />

    I guess you could do some code that runs when you save a product and creates a new rewriting rule that would look something like:

    <add name="DefaultProductRewrite" virtualUrl="yourcategory/yourproductname" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/shop/product.aspx?catalog=c-3&amp;product=p-123" ignoreCase="true" xmlns="" />

    That way when you hit http://yourdomain.com/yourcategory/yourproductname uCommerce would show you the product.

    /Michael

  • nug 11 posts 33 karma points
    Aug 21, 2012 @ 16:38
    nug
    0

    Yep that works.  But seems a little cumbersome to maintain for lots of products.  Anyone else?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 29, 2012 @ 10:11
    Søren Spelling Lund
    0

    You can change the way URLs are generated by overriding the IUrlService.

    Docs available at Nice URL with uCommerce.

  • nug 11 posts 33 karma points
    Oct 02, 2012 @ 18:11
    nug
    1

    Sorry forgot to update this thread!  Thanks Soren!  I'll have to take a closeer look at IUrlService.

    But fow now, since I only have 1 catalog, I was able to achieve what I needed by replacing the exising rules in UrlRewriting.config with the below and adding a bit of logic to my macros on the catalog.aspx & product.aspx pages.

    ~/products/a-product/mellow-yellow

    <add name="ProductsProductRewrite"

    virtualUrl="(.*)/products/(.*)"

    rewriteUrlParameter="ExcludeFromClientQueryString"

    destinationUrl="~/products/product.aspx?catalog=c-23&amp;product=$2"

    ignoreCase="true"

    xmlns="" />

    <add name="ProductsRewrite"

    virtualUrl="(.*)/products"

    rewriteUrlParameter="ExcludeFromClientQueryString"

    destinationUrl="~/products/catalog.aspx?catalog=c-23"

    ignoreCase="true"

    xmlns="" />

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 10, 2012 @ 08:54
    Søren Spelling Lund
    0

    Thanks for being awesome and posting your soluton in the thread :)

  • nug 11 posts 33 karma points
    Oct 17, 2012 @ 05:21
    nug
    0

    No problem!  I learn so much from these forums.

     

Please Sign in or register to post replies

Write your reply to:

Draft