Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » The best overloaded method match for 'Dynamicweb.Ecommerce.Shops.Shop.Shop(System.Data.IDataReader)' has some invalid arguments

The best overloaded method match for 'Dynamicweb.Ecommerce.Shops.Shop.Shop(System.Data.IDataReader)' has some invalid arguments

Bjørn Kamfjord
Reply

I tried to Upgrade from 9.3* to 9.4*. But this error throws me off. 


"Error compiling template "Designs/EG/eCom/Productlist/ProductList.cshtml" Line 29: 'Dynamicweb.Ecommerce.Products.Group.GetGroupById(string)' is obsolete: 'Use Services.ProductGroups.GetGroup instead.' Line 46: The best overloaded method match for 'Dynamicweb.Ecommerce.Shops.Shop.Shop(System.Data.IDataReader)' has some invalid arguments Line 46: Argument 1: cannot convert from 'string' to 'System.Data.IDataReader' Line 147: The best overloaded method match for 'Dynamicweb.Ecommerce.Shops.Shop.Shop(System.Data.IDataReader)' has some invalid arguments Line 147: Argument 1: cannot convert from 'string' to 'System.Data.IDataReader'

As far as I can tell, this is the helper at fault, at line 3. I'm not very good with C# so this probarly is an easy fix for someone more adept at coding than myself... 

@helper RenderEcomNavigation(Dynamicweb.Ecommerce.Products.GroupCollection groupCollection, int level, int catalogPageID, string currentGroupID)
{
groupCollection = (groupCollection == null) ? new Dynamicweb.Ecommerce.Shops.Shop(Dynamicweb.Frontend.PageView.Current().Area.EcomShopId).TopLevelGroups : groupCollection;

foreach (Dynamicweb.Ecommerce.Products.Group group in groupCollection)
{
    bool existsInBranch = (GetGroupAndSubGroups(group.Id).Where(node => node == currentGroupID).FirstOrDefault() != null) ? true : false;
    bool showInMenu = group.NavigationShowInMenu;

    if (showInMenu)
    {
            <li class='@(((group.Id == currentGroupID) || existsInBranch) ? "active" : string.Empty)'>
                <a href='/Default.aspx?ID=@catalogPageID&GroupID=@group.Id' class='@((group.Id == currentGroupID) ? "scheme_color" : "color_dark") d_block relative'>
                    @group.Name
                    @if (group.HasChildGroups)
                    {
                        <span class="bg_light_color_1 r_corners f_right color_dark talign_c"></span>
                    }
                </a>
                @if (group.HasChildGroups)
                {
                    <ul class='@((existsInBranch) ? string.Empty : "d_none")'>
                        @RenderEcomNavigation(group.Subgroups, (level + 1), catalogPageID, currentGroupID)
                    </ul>
                }
            </li>
    }
}
}


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

HI Bjørn,
could you replace the:

new Dynamicweb.Ecommerce.Shops.Shop(Dynamicweb.Frontend.PageView.Current().Area.EcomShopId)

to:

Dynamicweb.Ecommerce.Shops.ShopService.GetShop(Dynamicweb.Frontend.PageView.Current().Area.EcomShopId)

and

Dynamicweb.Ecommerce.Products.Group.GetGroupById(string)

to:
Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(groupId)

Regards, Dmitrij

 

 

 
Martin Vang
Martin Vang
Reply

I would suggest you use:

Dynamicweb.Ecommerce.Services.Shops.GetShop(Dynamicweb.Frontend.PageView.Current().Area.EcomShopId)

instead. Getting used to using this makes it much easier to find the correct service (use Dynamicweb.Services for content like pages etc.).

BR

Martin

 

You must be logged in to post in the forum