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?
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 {
}
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?
Hi Julian,
I have written an e-mail to you with an example. I hope that helps.
/Rune
Just facing this problem, what was the solution?
Hi James,
Throw me an e-mail and I will forward you the same mail I sent Julian. [email protected]
/Rune
I have the exact same problem. Could I please have the solution also! Also cant' override the GetOriginalUnitPrices method either.
Thank you
Hi Dean,
Of cause. Throw me an e-mail and I'll send it to you.
/Rune
Hi Rune,
Thanks! Slight problem, and this is probably as dumb as it sounds. How do I send you an email?
I spoke to Rune yesterday and I believe the fix should be to use the following
SuppressDependency
attributes on your class:Instead of the one mentioned in the docs:
Give this a try and let me know how you get on.
Matt
Hi Matt and Rune,
Thanks for sharing this. Everything works as expected now.
Cheers Dean
is working on a reply...