goods-exporter 1.4.8 → 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.
@@ -265,11 +265,13 @@ class InsalesFormatter {
265
265
  __publicField$9(this, "formatterName", "Insales");
266
266
  __publicField$9(this, "fileExtension", Extension.XLSX);
267
267
  }
268
- async format(writableStream, products, categories, _, __) {
268
+ async format(writableStream, products, categories, brands, __) {
269
269
  const mappedCategories = {};
270
270
  categories?.forEach(
271
271
  (category) => mappedCategories[category.id] = category
272
272
  );
273
+ const mappedBrands = {};
274
+ brands?.forEach((brand) => mappedBrands[brand.id] = brand);
273
275
  const getParams = (product) => {
274
276
  const properties = {};
275
277
  product.params?.forEach(
@@ -336,6 +338,7 @@ class InsalesFormatter {
336
338
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0410\u0440\u0442\u0438\u043A\u0443\u043B",
337
339
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041F\u043E\u043B (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
338
340
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0411\u0440\u0435\u043D\u0434 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
341
+ "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041B\u043E\u0433\u043E\u0442\u0438\u043F \u0431\u0440\u0435\u043D\u0434\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
339
342
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0421\u0435\u0440\u0438\u044F (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
340
343
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0414\u0430\u0442\u0430 \u0440\u0435\u043B\u0438\u0437\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
341
344
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B",
@@ -386,6 +389,7 @@ class InsalesFormatter {
386
389
  // TODO: брать из обычных параметров,
387
390
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041F\u043E\u043B (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.gender,
388
391
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0411\u0440\u0435\u043D\u0434 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.vendor,
392
+ "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041B\u043E\u0433\u043E\u0442\u0438\u043F \u0431\u0440\u0435\u043D\u0434\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.vendorId === void 0 ? void 0 : mappedBrands[product.vendorId]?.logoUrl,
389
393
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0421\u0435\u0440\u0438\u044F (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.seriesName,
390
394
  "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0414\u0430\u0442\u0430 \u0440\u0435\u043B\u0438\u0437\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.saleDate,
391
395
  ...getParams(product),
@@ -665,6 +669,12 @@ class WooCommerceFormatter {
665
669
  "Images",
666
670
  "SizeGrid"
667
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
+ });
668
678
  }
669
679
  formatKeyAttribute(key) {
670
680
  const keyWithoutInvalidCharacters = key.replaceAll(",", "").replaceAll(";", "");
@@ -705,14 +715,17 @@ class WooCommerceFormatter {
705
715
  const paramsMap = /* @__PURE__ */ new Map();
706
716
  const propertiesMap = /* @__PURE__ */ new Map();
707
717
  const uniqueAttributes = /* @__PURE__ */ new Map();
708
- const genderTitle = "\u041F\u043E\u043B";
718
+ Object.values(this.CUSTOM_ATTRIBUTES).forEach((attrName) => {
719
+ if (!uniqueAttributes.has(attrName)) {
720
+ uniqueAttributes.set(attrName, uniqueAttributes.size);
721
+ }
722
+ });
709
723
  formatedProducts.forEach((product) => {
710
724
  product.params?.forEach(({ key }) => {
711
725
  if (!uniqueAttributes.has(key)) {
712
726
  uniqueAttributes.set(key, uniqueAttributes.size);
713
727
  }
714
728
  });
715
- uniqueAttributes.set(genderTitle, uniqueAttributes.size);
716
729
  product.properties?.forEach(({ key }) => {
717
730
  if (!uniqueAttributes.has(key)) {
718
731
  uniqueAttributes.set(key, uniqueAttributes.size);
@@ -740,18 +753,30 @@ class WooCommerceFormatter {
740
753
  ([key2, value2]) => paramAttributes[key2] = value2
741
754
  );
742
755
  });
743
- const genderIndex = uniqueAttributes.get(genderTitle);
744
- const genderAttribute = this.createAttribute({
745
- name: genderTitle,
746
- id: genderIndex,
747
- values: product.gender,
748
- global: 0
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
+ }
749
779
  });
750
- if (genderAttribute) {
751
- Object.entries(genderAttribute).forEach(
752
- ([key, value]) => propertyAttributes[key] = value
753
- );
754
- }
755
780
  product.properties?.forEach(({ key, value }) => {
756
781
  const index = uniqueAttributes.get(key);
757
782
  if (index === void 0) {