Feature/paired item support (#3869)

* Add paired item helper and implement it in some nodes
This commit is contained in:
Omar Ajoue
2022-08-30 17:55:33 +02:00
committed by GitHub
parent 087d3f99f1
commit b2c674591c
150 changed files with 4027 additions and 1625 deletions

View File

@@ -312,7 +312,7 @@ export class Magento2 implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const timezone = this.getTimezone();
let responseData;
@@ -378,7 +378,7 @@ export class Magento2 implements INodeType {
body.password = password;
}
Object.assign(body.customer, rest);
Object.assign(body.customer!, rest);
responseData = await magentoApiRequest.call(this, 'POST', '/rest/V1/customers', body);
}
@@ -524,7 +524,7 @@ export class Magento2 implements INodeType {
body.password = password;
}
Object.assign(body.customer, rest);
Object.assign(body.customer!, rest);
responseData = await magentoApiRequest.call(
this,
@@ -675,7 +675,7 @@ export class Magento2 implements INodeType {
body.product!.custom_attributes = customAttributes?.customAttribute || {};
Object.assign(body.product, rest);
Object.assign(body.product!, rest);
responseData = await magentoApiRequest.call(
this,
@@ -790,7 +790,7 @@ export class Magento2 implements INodeType {
body.product!.custom_attributes = customAttributes?.customAttribute || {};
Object.assign(body.product, rest);
Object.assign(body.product!, rest);
responseData = await magentoApiRequest.call(
this,
@@ -801,18 +801,25 @@ export class Magento2 implements INodeType {
}
}
Array.isArray(responseData)
? returnData.push(...responseData)
: returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionErrorData);
continue;
}
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}