VariantParent is null

Pedro Costa asked on February 3, 2015 15:15

Hi,

Am implementing a custom transformation for the Shopping Cart Content web part, unfortunately the VariantParent is always null eventhough the SKU.IsProductVariant is true.

Could this be an issue?

For context, this is what I'm trying to do: <%# If(EvalBool("SKU.IsProductVariant"), Eval("VariantParent.SKUDescription"), Eval("SKU.SKUDescription")) %>

and am getting, [CMSAbstractTransformation.DataBind]: [CMSAbstractTransformation]: Hosted transformation object does not provide property 'VariantParent' to be able to evaluate expression 'VariantParent.SKUDescription'.

Thanks, P.

Correct Answer

Josef Dvorak answered on February 10, 2015 21:42

Hi,

We have been resolving this issue with Pedro via email. I am posting the solution in case anyone else comes across the same scenario.

This property is not accessible like the SKU object, because it is not registered as an object in the web part data source. This means that only its string representation is available for Eval. The reason why the SKU object is accessible is because it is Object dependency of ShoppingCartItemInfo object, so it is loaded automatically.

As a workaround, you can use this statement in your transformation:

CMS.Ecommerce.SKUInfoProvider.GetSKUInfo(Eval<int>("SKU.SKUParentSKUID")).SKUDescription

This will find the SKUInfo object among the Site SKU's based on the Parent SKUID.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.