n8n-nodes-prestashop8 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodes/PrestaShop8/PrestaShop8.node.description.js +98 -0
- package/dist/nodes/PrestaShop8/PrestaShop8.node.js +15 -3
- package/dist/nodes/PrestaShop8/fieldMappings.js +7 -0
- package/dist/nodes/PrestaShop8/types.js +2 -2
- package/dist/nodes/PrestaShop8/utils.js +1 -1
- package/package.json +1 -1
|
@@ -535,6 +535,104 @@ exports.PrestaShop8Description = {
|
|
|
535
535
|
required: true,
|
|
536
536
|
description: 'Whether the manufacturer is active (visible) or not.',
|
|
537
537
|
},
|
|
538
|
+
// === REQUIRED FIELDS FOR STOCK_AVAILABLES (UPDATE) ===
|
|
539
|
+
{
|
|
540
|
+
displayName: 'Product ID',
|
|
541
|
+
name: 'stockProductId',
|
|
542
|
+
type: 'number',
|
|
543
|
+
displayOptions: {
|
|
544
|
+
show: {
|
|
545
|
+
resource: ['stock_availables'],
|
|
546
|
+
operation: ['update'],
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
default: 0,
|
|
550
|
+
required: true,
|
|
551
|
+
placeholder: '1',
|
|
552
|
+
description: 'ID of the product (id_product)',
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
displayName: 'Product Attribute ID',
|
|
556
|
+
name: 'stockProductAttributeId',
|
|
557
|
+
type: 'number',
|
|
558
|
+
displayOptions: {
|
|
559
|
+
show: {
|
|
560
|
+
resource: ['stock_availables'],
|
|
561
|
+
operation: ['update'],
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
default: 0,
|
|
565
|
+
required: true,
|
|
566
|
+
placeholder: '0',
|
|
567
|
+
description: 'ID of the product combination/attribute (id_product_attribute). Use 0 for products without combinations',
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
displayName: 'Quantity',
|
|
571
|
+
name: 'stockQuantity',
|
|
572
|
+
type: 'number',
|
|
573
|
+
displayOptions: {
|
|
574
|
+
show: {
|
|
575
|
+
resource: ['stock_availables'],
|
|
576
|
+
operation: ['update'],
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
default: 0,
|
|
580
|
+
required: true,
|
|
581
|
+
placeholder: '100',
|
|
582
|
+
description: 'Available quantity in stock',
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
displayName: 'Depends On Stock',
|
|
586
|
+
name: 'stockDependsOnStock',
|
|
587
|
+
type: 'options',
|
|
588
|
+
displayOptions: {
|
|
589
|
+
show: {
|
|
590
|
+
resource: ['stock_availables'],
|
|
591
|
+
operation: ['update'],
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
options: [
|
|
595
|
+
{
|
|
596
|
+
name: 'Yes',
|
|
597
|
+
value: '1',
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: 'No',
|
|
601
|
+
value: '0',
|
|
602
|
+
},
|
|
603
|
+
],
|
|
604
|
+
default: '0',
|
|
605
|
+
required: true,
|
|
606
|
+
description: 'Whether stock management depends on warehouse stock',
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
displayName: 'Out Of Stock',
|
|
610
|
+
name: 'stockOutOfStock',
|
|
611
|
+
type: 'options',
|
|
612
|
+
displayOptions: {
|
|
613
|
+
show: {
|
|
614
|
+
resource: ['stock_availables'],
|
|
615
|
+
operation: ['update'],
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
options: [
|
|
619
|
+
{
|
|
620
|
+
name: 'Deny Orders',
|
|
621
|
+
value: '0',
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: 'Allow Orders',
|
|
625
|
+
value: '1',
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: 'Use Default',
|
|
629
|
+
value: '2',
|
|
630
|
+
},
|
|
631
|
+
],
|
|
632
|
+
default: '2',
|
|
633
|
+
required: true,
|
|
634
|
+
description: 'Behavior when product is out of stock',
|
|
635
|
+
},
|
|
538
636
|
// Additional Fields for CREATE (for non-required fields)
|
|
539
637
|
{
|
|
540
638
|
displayName: 'Additional Fields',
|
|
@@ -99,8 +99,9 @@ function collectRequiredFields(executeFunctions, resource, itemIndex) {
|
|
|
99
99
|
if (mappings) {
|
|
100
100
|
for (const [inputName, fieldName] of Object.entries(mappings)) {
|
|
101
101
|
const value = executeFunctions.getNodeParameter(inputName, itemIndex, '');
|
|
102
|
-
if (value) {
|
|
103
|
-
|
|
102
|
+
if (value !== '' && value !== null && value !== undefined) {
|
|
103
|
+
// Convert to string for XML generation
|
|
104
|
+
fieldsToCreate.push({ name: fieldName, value: String(value) });
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -463,7 +464,18 @@ class PrestaShop8 {
|
|
|
463
464
|
}
|
|
464
465
|
let body;
|
|
465
466
|
// Get fields to update (key-value pairs)
|
|
466
|
-
|
|
467
|
+
let fieldsToUpdate = this.getNodeParameter('fieldsToUpdate.field', i, []);
|
|
468
|
+
// For stock_availables, collect required fields from dedicated inputs
|
|
469
|
+
if (resource === 'stock_availables') {
|
|
470
|
+
const requiredFields = collectRequiredFields(this, resource, i);
|
|
471
|
+
// Merge required fields with additional fields, required fields take precedence
|
|
472
|
+
const existingFieldNames = fieldsToUpdate.map(f => f.name);
|
|
473
|
+
for (const reqField of requiredFields) {
|
|
474
|
+
if (!existingFieldNames.includes(reqField.name)) {
|
|
475
|
+
fieldsToUpdate.push(reqField);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
467
479
|
if (!rawMode) {
|
|
468
480
|
// Validate that at least one field is provided
|
|
469
481
|
if (!fieldsToUpdate || fieldsToUpdate.length === 0) {
|
|
@@ -34,6 +34,13 @@ exports.CREATE_FIELD_MAPPINGS = {
|
|
|
34
34
|
manufacturers: {
|
|
35
35
|
manufacturerName: 'name',
|
|
36
36
|
manufacturerActive: 'active'
|
|
37
|
+
},
|
|
38
|
+
stock_availables: {
|
|
39
|
+
stockProductId: 'id_product',
|
|
40
|
+
stockProductAttributeId: 'id_product_attribute',
|
|
41
|
+
stockQuantity: 'quantity',
|
|
42
|
+
stockDependsOnStock: 'depends_on_stock',
|
|
43
|
+
stockOutOfStock: 'out_of_stock'
|
|
37
44
|
}
|
|
38
45
|
};
|
|
39
46
|
/**
|
|
@@ -84,8 +84,8 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
84
84
|
},
|
|
85
85
|
stock_availables: {
|
|
86
86
|
name: 'stock_availables',
|
|
87
|
-
displayName: 'Available
|
|
88
|
-
description: '
|
|
87
|
+
displayName: 'Stock Available',
|
|
88
|
+
description: 'Product stock management (stock_availables)',
|
|
89
89
|
supportsCreate: false,
|
|
90
90
|
supportsUpdate: true,
|
|
91
91
|
supportsDelete: false,
|
|
@@ -565,7 +565,7 @@ exports.REQUIRED_FIELDS_BY_RESOURCE = {
|
|
|
565
565
|
'tax_rules': ['id_country', 'id_tax'],
|
|
566
566
|
'carriers': ['name', 'active'],
|
|
567
567
|
'order_states': ['name', 'color'],
|
|
568
|
-
'stock_availables': ['id_product', 'quantity'],
|
|
568
|
+
'stock_availables': ['id_product', 'id_product_attribute', 'quantity', 'depends_on_stock', 'out_of_stock'],
|
|
569
569
|
'images': ['id_product'],
|
|
570
570
|
'combinations': ['id_product'],
|
|
571
571
|
'tags': ['name', 'id_lang'],
|
package/package.json
CHANGED