Copied to clipboard

Flag this post as spam?

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


  • Julian 13 posts 83 karma points
    Jul 12, 2018 @ 15:09
    Julian
    0

    customising TeaCommerce

    Hi,

    I'm trying to create a simple override for the GetName method, in the documentation it suggests that this can be achieved with something similar to this, I have copied the GetName method from the original, but am returning "testName" just so that I confirm whether or not it is working

    namespace myNamespace {

    [SuppressDependency("TeaCommerce.Umbraco.Configuration.InformationExtractors.IPublishedContentProductInformationExtractor", "TeaCommerce.Umbraco.Configuration")]
    public class CustomPublishedContentProductInformationExtractor : PublishedContentProductInformationExtractor
    {
    
        public CustomPublishedContentProductInformationExtractor(IStoreService storeService, ICurrencyService currencyService, IVatGroupService vatGroupService, IVariantService<IPublishedContent, VariantPublishedContent> variantService)
            : base(storeService, currencyService, vatGroupService, variantService)
        {
        }
    
        public override string GetName(IPublishedContent product, VariantPublishedContent variant = null)
        {
            string name = GetPropertyValue<string>(product, Constants.ProductPropertyAliases.NamePropertyAlias, variant, recursive: variant == null);
    
            //If no name is found - default to the umbraco node name
            if (string.IsNullOrEmpty(name))
            {
                if (variant != null)
                {
                    name = GetPropertyValue<string>(product, Constants.ProductPropertyAliases.NamePropertyAlias);
                }
                if (variant == null)
                {
                    name = product.Name;
                }
                if (variant != null)
                {
                    name += " - " + variant.Name;
                }
            }
    
            return "test name";
    
            //return product.GetVortoValue<string>("productName") + (variant != null ? " - " + variant.GetVortoValue<string>("productName") : "");
        }
    }
    

    }

    I would expect that any products that are added to my order would appear as "test name". But it seems to be using the default productName/ variant combination, not using my overridden version, am I misunderstanding/ missing something?

  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 13, 2018 @ 10:56
    Rune Grønkjær
    0

    Hi Julian,

    I have written an e-mail to you with an example. I hope that helps.

    /Rune

  • James Kahler 36 posts 78 karma points
    Aug 03, 2018 @ 12:17
    James Kahler
    0

    Just facing this problem, what was the solution?

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 06, 2018 @ 06:16
    Rune Grønkjær
    0

    Hi James,

    Throw me an e-mail and I will forward you the same mail I sent Julian. rg@teasolutions.dk

    /Rune

  • Dean 55 posts 98 karma points
    Jan 30, 2019 @ 01:19
    Dean
    0

    I have the exact same problem. Could I please have the solution also! Also cant' override the GetOriginalUnitPrices method either.

    Thank you

  • Rune Grønkjær 1372 posts 3103 karma points
    Jan 30, 2019 @ 06:58
    Rune Grønkjær
    0

    Hi Dean,

    Of cause. Throw me an e-mail and I'll send it to you.

    /Rune

  • Dean 55 posts 98 karma points
    Jan 30, 2019 @ 20:40
    Dean
    0

    Hi Rune,

    Thanks! Slight problem, and this is probably as dumb as it sounds. How do I send you an email?

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jan 31, 2019 @ 11:45
    Matt Brailsford
    0

    I spoke to Rune yesterday and I believe the fix should be to use the following SuppressDependency attributes on your class:

    [SuppressDependency( "TeaCommerce.Api.InformationExtractors.IProductInformationExtractor", "TeaCommerce.Api" )]
    [SuppressDependency( "TeaCommerce.Api.InformationExtractors.IProductInformationExtractor`1[[Umbraco.Core.Models.IPublishedContent, Umbraco.Core]]", "TeaCommerce.Api" )]
    [SuppressDependency( "TeaCommerce.Api.InformationExtractors.IProductInformationExtractor`2[[Umbraco.Core.Models.IPublishedContent, Umbraco.Core],    [TeaCommerce.Umbraco.Configuration.Variants.Models.VariantPublishedContent, TeaCommerce.Umbraco.Configuration]]", "TeaCommerce.Api" )]
    

    Instead of the one mentioned in the docs:

    [SuppressDependency("TeaCommerce.Umbraco.Configuration.InformationExtractors.IPublishedContentProductInformationExtractor", "TeaCommerce.Umbraco.Configuration")]
    

    Give this a try and let me know how you get on.

    Matt

  • Dean 55 posts 98 karma points
    Jan 31, 2019 @ 21:53
    Dean
    0

    Hi Matt and Rune,

    Thanks for sharing this. Everything works as expected now.

    Cheers Dean

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies