on ‎2018 Jul 05 10:57 AM
I've searched in experts and found a question regarding this topic but since its over 3 years old I decided to create a new one because the given solution is not working for me. I've followed the instructions as described in help: help.hybris: Importing Products and orders
I should mention that the price is set to the orderentry not the product but using the recalculate button in backoffice works just fine, so i suppose it should work form impex as well.
insert_update order;code[unique=true];user(uid);date[dateformat='yyyy-MM-dd HH:mm:ss'];currency(isocode);paymentCost;totalPrice;deliveryCost;deliveryCostNet;calculated ;752865;name@email.com;2016-01-01 14:30:40;EUR;0;0;10;12;false
Import:
insert_update orderentry;order(code);product(catalogVersion(catalog(id[default = 'ProductCatalog']),version[default = 'Staged']),code);unit(code);quantity;totalprice;baseprice;basePriceNet;calculated;entryNumber[unique=true, default = -1]
;752865;40404001;pieces;3;410,79;136,93;115,063333333333;false
insert_update order;code[unique=true]
#% impex.getLastImportedItem().recalculate();
;752865;
There is a product existing with code=40404001
Problem:
So the Problem is that the order is not recalculated. The price is still 0 and calculated is set to false
I would expect that the Order is actually calculated and all prices are set according to the delivery cost and orderentrys.
This is actually achieved when clicking the corresponding recalculate button in the backoffice for one Order.
(Since this is a data migration with over 100k orders no talk about using the button)
Advanced:
I even encounter a problem with aftereach:
insert_update order;code[unique=true]
#%aftereach: impex.getLastImportedItem().recalculate();
;752865;
#%afterEach:end
Adding aftereach to execution results in a big error message in the log, summing up to: Exception ocurred, will ignore: de.hybris.platform.impex.jalo.ImpExException: error executing code line at 8 : Sourced file: inline evaluation of: ``impex.getLastImportedItem().recalculate();'' : Method Invocation recalculate[HY--1]
Request clarification before answering.
I'm assuming that you are running this impex from the hAC. Are you sure it's not something as simple as you haven't ticked the Enable code execution box in settings? It's off by default.

For example, this works for me against a default Powertools store.
INSERT_UPDATE Order;code[unique=true];date;currency(isocode);user(uid)
;12345;Jul 30, 2018 10:00:00 AM;USD;anonymous
INSERT_UPDATE OrderEntry;order(code)[unique=true];entryNumber[unique=true];product(code,catalogVersion(catalog(id),version));unit(code)[default=pieces];quantity[default=1];calculated[default=false]
;12345;-1;1128762:powertoolsProductCatalog:Online
INSERT_UPDATE Order;code[unique=true]
#%aftereach: impex.getLastImportedItem().recalculate()
;12345
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
no one has an idea why this is not working...?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
still up for help, since the recalculation is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.