Catalog routing issue, causing incorrect URL

Vote:
 

I'm using the Sample store for EPiServer 7.5 as base for the website.

I have upgraded to the latest version through nuget.

I have added a seperate catalog along side with the standard in the sample proejct.

I  created an advertisement block

    [ContentType(DisplayName = "AdvertisementBlock", GUID = "e9eb4ae4-41df-4346-bf1d-1c319e99531e", Description = "Create an advert")]
    public class AdvertisementBlock : BlockData
    {
        [Display(   Name="Image",
                    Description="Image to show in advert",
                    GroupName = SystemTabNames.Content,
                    Order=1)]
        [UIHint( EPiServer.Web.UIHint.Image)]
        public virtual Url Image { get; set; }

        [Display(   Name = "Product Link",
                    Description = "Link to the product",
                    GroupName = SystemTabNames.Content,
                    Order = 10)]
        public virtual Url ProductLink { get; set; }

        [Display(   Name = "Description",
                    Description = "Short description",
                    GroupName = SystemTabNames.Content,
                    Order = 10)]
        public virtual string Description { get; set; }
    }

And i created a control for this:

<a href="<%=CurrentBlock.ProductLink %>">
    <EPiServer:Property ID="ImagePoperty" PropertyName="Image" runat="server" />
    <EPiServer:Property ID="DescriptionProperty" PropertyName="Description" runat="server" />
</a>

with codebehind

    public partial class AdvertisementBlockControl : BlockControlBase<AdvertisementBlock>
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }

For som reason the url created from product link is

 http://dev:17003/-1073741823/<catalogroot>/<categorynode>/

The problem here is the underlined segement. if copy the link and remove that part the url works and i get to the correct category or product.

Where whould I direct my focus. Is it something in my routing that i've missed? I'm basically using the sample store out of the box, just changed the markup and rendering templates for metaclasses.

The other links on the site works as intended.

#86467
May 22, 2014 10:55
Vote:
 

Hi,

I don't see any code you assign value to ProductLink. Can you show it here?

Regards.

/Q

#86472
May 22, 2014 11:52
Vote:
 

I don't assign it from code, It's a url, that i assign when i create the block in edit mode. I get a catalog browser and i can choose a node and save the block.

#86479
May 22, 2014 12:51
Vote:
 

Your block looks perfect Mikael, I have it work on my site. What CMS and Commerce versions do you have in your site? And have you injected any custom routing?

#86531
May 23, 2014 8:52
Vote:
 

No, i'm using the standard from the sample site. Attached it below.

    [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
    public class InitializationModule : IConfigurableModule
    {
        public void Initialize(InitializationEngine context)
        {
            MapRoutes(RouteTable.Routes);

            // Check the HostType is WebApplication
            if (context == null || context.HostType != HostType.WebApplication)
            {
                return;
            }

            AddAssociationGroups(context);

            // Init only in Web context type and first loading time of EPiServer Commerce Sample Site
            if (SettingFactory.Instance.Setting.IsSampleDataConfigured)
                return;

            // switch the flag
            SettingFactory.Instance.Setting.IsSampleDataConfigured = true;
            SettingFactory.Instance.Save();
        }

        private static void MapRoutes(RouteCollection routes)
        {
            CatalogRouteHelper.MapDefaultHierarchialRouter(routes, false);
        }

        public void Preload(string[] parameters)
        {
        }

        public void Uninitialize(InitializationEngine context)
        {
        }

        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Container.Configure(c => c.For<ICurrentMarket>().Singleton().Use<DinTidning.Commerce.Helpers.MarketStorage>());
        }

        private void AddAssociationGroups(InitializationEngine context)
        {
            // Add predefined selections CrossSell and UpSell
            // If they already exist nothing will be added
            var associationDefinitionRepository =
                context.Locate.Advanced.GetInstance<GroupDefinitionRepository<AssociationGroupDefinition>>();
            associationDefinitionRepository.Add(new AssociationGroupDefinition { Name = Constants.CrossSellGroupName });
            associationDefinitionRepository.Add(new AssociationGroupDefinition { Name = Constants.UpSellGroupName });
        }
    }
#86532
May 23, 2014 8:58
Vote:
 
<packages>
  <package id="Castle.Core" version="3.2.2" targetFramework="net40" />
  <package id="Castle.Windsor" version="3.2.1" targetFramework="net40" />
  <package id="Common.Logging" version="1.2.0" targetFramework="net40" />
  <package id="Common.Logging.EntLib" version="1.2.0" targetFramework="net40" />
  <package id="Common.Logging.Log4Net" version="1.2.0" targetFramework="net40" />
  <package id="Common.Logging.NLog" version="1.2.0" targetFramework="net40" />
  <package id="DotNetZip" version="1.9.1.8" targetFramework="net40" />
  <package id="EPiServer.CMS.Core" version="7.7.0" targetFramework="net40" />
  <package id="EPiServer.CMS.UI" version="7.8.0" targetFramework="net40" />
  <package id="EPiServer.CMS.UI.Core" version="7.8.0" targetFramework="net40" />
  <package id="EPiServer.Commerce" version="7.7.2" targetFramework="net40" />
  <package id="EPiServer.Commerce.Core" version="7.7.2" targetFramework="net40" />
  <package id="EPiServer.Commerce.UI" version="7.7.2" targetFramework="net40" />
  <package id="EPiServer.CommonFramework" version="7.5.446.2" targetFramework="net40" />
  <package id="EPiServer.Framework" version="7.7.0" targetFramework="net40" />
  <package id="log4net" version="1.2.10" targetFramework="net40" />
  <package id="Lucene.Net" version="3.0.3" targetFramework="net40" />
  <package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net40" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
  <package id="MicrosoftReportViewerWebForms_v10" version="1.0.0" targetFramework="net40" />
  <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
  <package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
  <package id="structuremap" version="2.6.4.1" targetFramework="net40" />
</packages>
#86537
May 23, 2014 9:38