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.

  • Sivasamy 13 posts 33 karma points
    May 30, 2013 @ 16:51
    Sivasamy
    0

    Adding new domain for mobile version using the same store

    Hi,

    We are working on a project that initially requested for displaying content on PCs. In this project we have created different stores for different countries and associated to the respective domains. 

    Now our client has requested us to add mobile version for the same site for each country. Since we couldn't convert the project now to responsive UI, we would like to add new domain for the same store for each country.

    We heard that we could opt for multiple domain license, but we are not sure about it.

    Any advices will be helpful for us to proceed with this.

    Thanks in advance.

    - Siva

  • Morten Skjoldager 440 posts 1499 karma points
    May 31, 2013 @ 13:30
    Morten Skjoldager
    0

    Hi Siva. The reason you're struggeling with that problem is that you have 1 hostname assigned for one store in the backend.

    Fortunatly the logic that drives that is very easy to override so you can extract the same store on yoursite.com and m.yoursite.com. 

    Here's a little code example for you to work on;

    public class MyCatalogContext : CatalogContext
    {
        private static IOrderedEnumerable<Domain> _domains;

        public MyCatalogContext(IDomainService domainService)
        {
    if (_domains == null)
    _domains = domainService.GetDomains().OrderByDescending(d => d.DomainName.Length);
        }

    public override string CurrentCatalogGroupName
        {
            get
            {
    if (string.IsNullOrEmpty(_catalogGroupName))
    _catalogGroupName = FindProductCatalogGroupForDomain().Name;

    // If group is not found for domain without mobile prefix,
    // use default strategy from base
    if (_catalogGroupName == null)
    _catalogGroupName = base.CurrentCatalogGroupName;

            return _catalogGroupName;
            }
    set
    {
    _catalogGroupName = value;
    }
        }

        private ProductCatalogGroup FindProductCatalogGroupForDomain()
        {
            ProductCatalogGroup currentGroup = null;

            string hostnameWithoutMobilePrefix =
            HttpContext.Current.Request.Url.OriginalString.Replace("m.", "");

            // Try to get a group with first matching domain in the ordered enumerable.
            foreach (var domain in _domains)
            {
                if (hostnameWithoutMobilePrefix.Contains(domain.DomainName))
                {
                    currentGroup = ProductCatalogGroup.FirstOrDefault(x => x.DomainId == domain.DomainId && !x.Deleted);
                    break;
                }
            }
            return currentGroup;
        }
    }

  • Morten Skjoldager 440 posts 1499 karma points
    May 31, 2013 @ 13:32
    Morten Skjoldager
    0
    Once the class is compiled put the DLL in the /bin folder and register the new catalog context  in /umbraco/ucommerce/configuration/Custom.config like so (make sure and update the bold bits with your own namespace and DLL names):

    id="CatalogContext"
    service="UCommerce.Runtime.ICatalogContext, UCommerce"
    type="MyNamespace.MyCatalogContext, MyDll"/>

    That should do the trick. 
    In short all you have to do is override the CurrentCatalogContext mathcing the logic you want. This was a code example i found somewhere else. You might need to alter it for your needs. 
    If you struggle further, please let me know
    Regards
    Morten
  • Sivasamy 13 posts 33 karma points
    May 31, 2013 @ 14:41
    Sivasamy
    0

    Thanks a lot Morten!

    We would try this approach and will let you know.

  • Morten Skjoldager 440 posts 1499 karma points
    Jun 03, 2013 @ 10:21
    Morten Skjoldager
    0

    Sounds great. 

    Looking forward to hearing from you.

    Regards

    Morten

  • Vignesh 3 posts 23 karma points
    Jun 05, 2013 @ 15:59
    Vignesh
    0

    Thanks Morten, The solution was working fine. but we are override the "CurrentCatalogGroup" property.

     

  • Morten Skjoldager 440 posts 1499 karma points
    Jun 07, 2013 @ 15:26
    Morten Skjoldager
    0

    Sounds great. Let me know if you have any issues in the future.

Please Sign in or register to post replies

Write your reply to:

Draft