Copied to clipboard

Flag this post as spam?

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


  • Kyle Eck 130 posts 280 karma points
    Feb 18, 2022 @ 15:56
    Kyle Eck
    0

    Vendr 2.1.0 Breaking Changes Error

    Matt,

    Just upgraded to Vendr 2.1.0 from 2.0.4, walking up the upgrade path one at a time and read through the breaking changes, but wanted to confirm with you.

    I have an extension method like such:

            public static IProductSnapshot AsVendrProduct(this IPublishedContent content)
        {
            return VendrApi.Instance.GetProduct(content.GetProductReference(), null);
        }
    

    Which then i use like this:

    priceRange = product.AsVendrProduct().Prices.First().Value.ToString("C");
    

    With your breaking changes it is my understanding that I will now need to pass a store Id to my extension method inside .AsVendrProduct() correct?

    Perhaps I'm mis interpreting your changes. However my site breaks on the priceRange line with the following error: enter image description here

    Thanks

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Feb 18, 2022 @ 16:18
    Matt Brailsford
    100

    Hi Kyle,

    Yea, that's correct you need to pass a store. But you've just reminded me, I haven't yet updated Vendr Checkout (though I have updated the demo store).

    This is what I changed it to in the Vendr Demo store https://github.com/vendrhub/vendr-demo-store/blob/v2/netcore/main/src/Vendr.DemoStore/Extensions/PublishedContentExtensions.cs#L40

        public static IProductSnapshot AsVendrProduct(this IProductComp content)
        {
            var page = content as IPublishedContent;
            if (page == null)
                return null;
    
            var store = page.GetStore();
    
            return VendrApi.Instance.GetProduct(store.Id, content.GetProductReference(), Thread.CurrentThread.CurrentCulture.Name);
        }
    

    Ultimately, the front end generally knows what the store is, so it's now just the codes responsibility to tell the ProductAdapeter rather than it "magically knowing" which has caused issues for people creating complex custom product adapters.

    Matt

  • Syed Asad Ali 2 posts 71 karma points
    Oct 25, 2022 @ 13:40
    Syed Asad Ali
    0

    In this Mr Matt a method is used GetHomePage() in this the Datatype is homePage please explain me what is homePage and it is giving error in my solution

  • Kyle Eck 130 posts 280 karma points
    Feb 18, 2022 @ 16:24
    Kyle Eck
    0

    Interesting,

    Ive implemented your code and understand it, hwoever i still return the error:

    -       $exception  {"Method not found: 'Vendr.Core.Models.IProductSnapshot Vendr.Core.Services.IProductService.GetProduct(System.String, System.String, System.String)'."} System.MissingMethodException
    

    Am I missing another dependency that wasnt updated or something as it looks like the GetProduct is looking for 2 params not 3?

  • Kyle Eck 130 posts 280 karma points
    Feb 18, 2022 @ 16:25
    Kyle Eck
    0

    Ah or perhaps was that from the .Net Core branch? To be clear Im still running U8 under .NET 4.7.2

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Feb 18, 2022 @ 16:26
    Matt Brailsford
    0

    Sorry, yea, that was the .NET Core branch. I should have asked, but it was 50/50 😁

    Matt

  • Kyle Eck 130 posts 280 karma points
    Feb 18, 2022 @ 16:38
    Kyle Eck
    1

    I just checked all of the dependency versions for things like Vendr.Core.Models and nuget is reporting they are 2.1.0, however when browsing in code to IProductSnapshot it looks like it is still trying to reference an old dependency 2.0.4 exactly

  • Kyle Eck 130 posts 280 karma points
    Feb 18, 2022 @ 16:42
    Kyle Eck
    1

    Actually, I fixed it and found a rogue old assembly in another project.

    Now im battling Vendr Checkout reference issues

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Feb 21, 2022 @ 09:31
    Matt Brailsford
    0

    Glad you were able to fix this one 👍

Please Sign in or register to post replies

Write your reply to:

Draft