Showing results for 
Search instead for 
Did you mean: 

Type Casting in Impex Export

Active Participant

Hi All,

Is it possible to do type casting when exporting through impex export?

for example I have CustomProductModel that extends OOTB ProductModel, in that CustomProductModel I have myAttribute field.

From it's variantProductModel, can I get myAttribute field? If I want to get CustomProductModel's code from variantProductModel we could write an impex like this since code is also part of OOTB ProductModel :

INSERT_UPDATE variantProduct;code[unique=true];baseProduct(code);


INSERT_UPDATE variantProduct;code[unique=true];baseProduct(myAttribute) 
won't work because baseProduct of variantProductModel is registered as OOTB ProductModel, which doesn't have myAttribute field.

In java we could get myAttribute by casting baseProduct to CustomProductModel :

String myAttribute = ((CustomProductModel) variantProductModel.getBaseProduct()).getMyAttribute();

So, is it possible to cast type of baseProduct in impex so it could read myAttribute?

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Participant

So actually this is possible, all you have to do is write down the model name first before the attribute name :

INSERT_UPDATE variantProduct;code[unique=true];baseProduct(CustomProduct.myAttribute)

If myAttribute is a model, and I want to get its code, then I can write it like this :

INSERT_UPDATE variantProduct;code[unique=true];baseProduct(CustomProduct.myAttribute(code))