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 1243 posts 2740 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 1243 posts 2740 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

Please Sign in or register to post replies

Write your reply to:

Draft