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
    1 week ago
    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 1228 posts 2692 karma points
    1 week ago
    Rune Grønkjær
    0

    Hi Julian,

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

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft