cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PriceRow excel import functionality

Former Member
0 Kudos
1,039

Hi ,

I implemented PriceRow excel import functionality using excelImport action, wrote custom translators and validators, however when I wanted to import "productId" or "Product" for PriceRow, these attributes aren't supported as they are having write="false"

In OOTB excel import/export classes isSupported() Method they are checking the attributeDescriptorModel.getWritable() for which "productId" & "product" will always return false.

How to import/export these through excel ?

Also when I tried exporting PriceRow the columns in the exported excel are mismatching.

for e.g in Customer column I'm getting prices and vice versa.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member638520
Contributor
0 Kudos

Hi,

Which class has isSupported() method? You can always try to override this method and change the condition.

Regards,

Lukasz

Former Member
0 Kudos

Thanks for immediate response.

ExcelExportRenderer.Because of that I guess in the export wizard I'm not able to see productId attribute.

Also productId is of type String , so OOTB ExcelJavaTypeTranslator should handle this, But for this attribute since write=false. I guess its not handling.Is my understanding correct?

former_member638520
Contributor
0 Kudos

Furtunately this method is protected, so you can easily override that and remove attr.getWritable() condition 😉

Regards,

Lukasz

Former Member
0 Kudos

Yes, for export I can probably override.

For import

As productId in PriceRow is of type String, OOTB ExcelJavaTypeTranslator should handle that, but it isn't.

former_member638520
Contributor
0 Kudos

Add the following property to your local.properties:

backoffice.excel.utility.sheets.hidden=false

Then export file once again and unhide typeSystem sheet. Check whether productId row is populated.

Regards,

Lukasz

Former Member
0 Kudos

link text

Hi,

Not able to see productId row. Attaching the sheet for reference.

But from your comment, I manually added the productId row in the template and then I'm able to import excel.

Cheers.

Thanks.

former_member638520
Contributor
0 Kudos

I expect that the same condition is in DefaultExcelExportDivider. Probably you will have to override this class as well.

Former Member
0 Kudos

Okay ! I'll override this method and put a condition only for this PriceRow Type & i guess it works.Thanks for helping me.

But can I know why that condition is checked OOTB ? so that I can know the impact if I change.

Thanks.

former_member638520
Contributor
0 Kudos

In excel you don't have control over cell value, so you cannot prohibit user to change values which are not writable. So I suppose that was the reason. Nevertheless it seems that this restriction can cause some problems, so I'll check whether it will be possible to change it in OOTB implementation.

Regards,

Lukasz

Former Member
0 Kudos

Hi,

Overrided the OOTB class isSupported() Method for Pricerow type & now it exports that specific column.

However if we unhide the typesystem sheet "productId " isn't populated. If I generate & download excel template , typssystem sheet doesnt contain "productId"

I guess in class DefaultExcelTemplateService populateTypeSystemSheet() method ,in this method too same condition is checked.

Thanks.

former_member638520
Contributor
0 Kudos

You're absolutely right. DefaultExcelTemplateService has protected populateTypeSystemSheet method with the following condition: .filter(attribute -> BooleanUtils.isTrue(attribute.getReadable()) && BooleanUtils.isTrue(attribute.getWritable())) You need to change the condition in this place as well.

Regards,

Lukasz

Former Member
0 Kudos

Hi Lukasz,

As the itemtype is PriceRow, I need a combination of productId & price to be unique.

So I overwritten the OOTB JavaTypeTranslator class importValue() method to return unique=true for productId & price attributes.

for productId in impex header unique=true is appended, but for price it isn't appended because in OOTB DefaultImpexConverter , prepareHeaderAttribute() method they are checking this condition

!PriceRowModel.PRICE.equalsIgnoreCase(headerAttribute.getName() because of which price is not unique.

so productId is only unique and I Cant upload multiple rows with same id

former_member638520
Contributor
0 Kudos

Hi,

I don't know why this condition is there, but try to override this service. I'll create ticket for removing this condition, but it will be done in next version

Regards,

Lukasz

Answers (0)