goods-exporter 1.4.9 → 1.4.10
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/LICENSE +21 -21
- package/README.md +106 -106
- package/dist/bundle.d.ts +1 -0
- package/dist/cjs/index.cjs +34 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +34 -13
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -669,6 +669,12 @@ class WooCommerceFormatter {
|
|
|
669
669
|
"Images",
|
|
670
670
|
"SizeGrid"
|
|
671
671
|
]);
|
|
672
|
+
__publicField$3(this, "CUSTOM_ATTRIBUTES", {
|
|
673
|
+
gender: "\u041F\u043E\u043B",
|
|
674
|
+
vendor: "\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C",
|
|
675
|
+
vendorCode: "\u0410\u0440\u0442\u0438\u043A\u0443\u043B",
|
|
676
|
+
seriesName: "\u0421\u0435\u0440\u0438\u044F"
|
|
677
|
+
});
|
|
672
678
|
}
|
|
673
679
|
formatKeyAttribute(key) {
|
|
674
680
|
const keyWithoutInvalidCharacters = key.replaceAll(",", "").replaceAll(";", "");
|
|
@@ -709,14 +715,17 @@ class WooCommerceFormatter {
|
|
|
709
715
|
const paramsMap = /* @__PURE__ */ new Map();
|
|
710
716
|
const propertiesMap = /* @__PURE__ */ new Map();
|
|
711
717
|
const uniqueAttributes = /* @__PURE__ */ new Map();
|
|
712
|
-
|
|
718
|
+
Object.values(this.CUSTOM_ATTRIBUTES).forEach((attrName) => {
|
|
719
|
+
if (!uniqueAttributes.has(attrName)) {
|
|
720
|
+
uniqueAttributes.set(attrName, uniqueAttributes.size);
|
|
721
|
+
}
|
|
722
|
+
});
|
|
713
723
|
formatedProducts.forEach((product) => {
|
|
714
724
|
product.params?.forEach(({ key }) => {
|
|
715
725
|
if (!uniqueAttributes.has(key)) {
|
|
716
726
|
uniqueAttributes.set(key, uniqueAttributes.size);
|
|
717
727
|
}
|
|
718
728
|
});
|
|
719
|
-
uniqueAttributes.set(genderTitle, uniqueAttributes.size);
|
|
720
729
|
product.properties?.forEach(({ key }) => {
|
|
721
730
|
if (!uniqueAttributes.has(key)) {
|
|
722
731
|
uniqueAttributes.set(key, uniqueAttributes.size);
|
|
@@ -744,18 +753,30 @@ class WooCommerceFormatter {
|
|
|
744
753
|
([key2, value2]) => paramAttributes[key2] = value2
|
|
745
754
|
);
|
|
746
755
|
});
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
756
|
+
Object.entries(this.CUSTOM_ATTRIBUTES).forEach(([field, attrName]) => {
|
|
757
|
+
const value = product[field];
|
|
758
|
+
if (value) {
|
|
759
|
+
const index = uniqueAttributes.get(attrName);
|
|
760
|
+
if (index === void 0) {
|
|
761
|
+
console.error(
|
|
762
|
+
`\u041D\u0435 \u043D\u0430\u0448\u043B\u043E\u0441\u044C \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 \u0434\u043B\u044F \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u043E\u0433\u043E \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 - ${attrName}`
|
|
763
|
+
);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (!paramAttributes[`Attribute ${index} name`]) {
|
|
767
|
+
const attribute = this.createAttribute({
|
|
768
|
+
name: attrName,
|
|
769
|
+
id: index,
|
|
770
|
+
values: value,
|
|
771
|
+
global: 0
|
|
772
|
+
});
|
|
773
|
+
if (!attribute) return;
|
|
774
|
+
Object.entries(attribute).forEach(
|
|
775
|
+
([key, val]) => propertyAttributes[key] = val
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
753
779
|
});
|
|
754
|
-
if (genderAttribute) {
|
|
755
|
-
Object.entries(genderAttribute).forEach(
|
|
756
|
-
([key, value]) => propertyAttributes[key] = value
|
|
757
|
-
);
|
|
758
|
-
}
|
|
759
780
|
product.properties?.forEach(({ key, value }) => {
|
|
760
781
|
const index = uniqueAttributes.get(key);
|
|
761
782
|
if (index === void 0) {
|