Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 07f6d3c

Browse files
author
Tomasz Kostuch
authored
Merge pull request #480 from gibkigonzo/bugfix/477
use productEquals to compare products in o2m
2 parents f106bbc + 3f77285 commit 07f6d3c

File tree

7 files changed

+38
-239
lines changed

7 files changed

+38
-239
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [1.12.2] - UNRELEASED
88

9+
### Added
10+
11+
912
### Fixed
1013

1114
- Fix default value for `maxAgeForResponse` - @lauraseidler (#485)
15+
- Adds `vsf-utlilities`. Use productEquals to compare products in o2m - @gibkigonzo (#477)
1216

1317
## [1.12.2] - UNRELEASED
1418

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"storefront-query-builder": "https://github.com/DivanteLtd/storefront-query-builder.git",
9494
"syswide-cas": "latest",
9595
"tsconfig-paths": "^3.9.0",
96+
"vsf-utilities": "^1.0.1",
9697
"winston": "^2.4.2"
9798
},
9899
"devDependencies": {

src/lib/taxcalc.js

Lines changed: 0 additions & 231 deletions
This file was deleted.

src/platform/magento1/tax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import AbstractTaxProxy from '../abstract/tax'
2-
import { calculateProductTax, checkIfTaxWithUserGroupIsActive, getUserGroupIdToUse } from '../../lib/taxcalc'
2+
import { calculateProductTax, checkIfTaxWithUserGroupIsActive, getUserGroupIdToUse } from 'vsf-utilities'
33
import TierHelper from '../../helpers/priceTiers'
44
import bodybuilder from 'bodybuilder'
55
import es from '../../lib/elastic'

src/platform/magento2/o2m.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { productsEquals } from 'vsf-utilities'
12

23
const Magento2Client = require('magento2-rest-client').Magento2Client;
34

@@ -107,9 +108,7 @@ function processSingleOrder (orderData, config, job, done, logger = console) {
107108
logger.info(THREAD_ID + '> ... and serverItems', serverItems)
108109

109110
for (const clientItem of clientItems) {
110-
const serverItem = serverItems.find((itm) => {
111-
return itm.sku === clientItem.sku || itm.sku.indexOf(clientItem.sku + '-') >= 0 /* bundle products */
112-
})
111+
const serverItem = serverItems.find(itm => productsEquals(itm, clientItem))
113112
if (!serverItem) {
114113
logger.info(THREAD_ID + '< No server item for ' + clientItem.sku)
115114
syncPromises.push(api.cart.update(null, cartId, { // use magento API
@@ -134,9 +133,7 @@ function processSingleOrder (orderData, config, job, done, logger = console) {
134133

135134
for (const serverItem of serverItems) {
136135
if (serverItem) {
137-
const clientItem = clientItems.find((itm) => {
138-
return itm.sku === serverItem.sku || serverItem.sku.indexOf(itm.sku + '-') >= 0 /* bundle products */
139-
})
136+
const clientItem = clientItems.find(itm => productsEquals(itm, serverItem))
140137
if (!clientItem) {
141138
logger.info(THREAD_ID + '< No client item for ' + serverItem.sku + ', removing from server cart') // use magento API
142139
syncPromises.push(api.cart.delete(null, cartId, { // delete server side item if not present if client's cart

src/platform/magento2/tax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import AbstractTaxProxy from '../abstract/tax'
2-
import { calculateProductTax, checkIfTaxWithUserGroupIsActive, getUserGroupIdToUse } from '../../lib/taxcalc';
2+
import { calculateProductTax, checkIfTaxWithUserGroupIsActive, getUserGroupIdToUse } from 'vsf-utilities';
33
import TierHelper from '../../helpers/priceTiers'
44
import es from '../../lib/elastic'
55
import bodybuilder from 'bodybuilder'

yarn.lock

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,14 @@ buffer@4.9.1:
12141214
ieee754 "^1.1.4"
12151215
isarray "^1.0.0"
12161216

1217+
buffer@5.6.0:
1218+
version "5.6.0"
1219+
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.6.0.tgz#a31749dc7d81d84db08abf937b6b8c4033f62786"
1220+
integrity sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==
1221+
dependencies:
1222+
base64-js "^1.0.2"
1223+
ieee754 "^1.1.4"
1224+
12171225
bytes@3.0.0:
12181226
version "3.0.0"
12191227
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
@@ -4365,6 +4373,11 @@ lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.5:
43654373
version "4.17.14"
43664374
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
43674375

4376+
lodash@^4.17.19:
4377+
version "4.17.19"
4378+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
4379+
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
4380+
43684381
longest@^1.0.1:
43694382
version "1.0.1"
43704383
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
@@ -6329,6 +6342,13 @@ sha1@^1.1.1:
63296342
charenc ">= 0.0.1"
63306343
crypt ">= 0.0.1"
63316344

6345+
sha3@^2.1.3:
6346+
version "2.1.3"
6347+
resolved "https://registry.yarnpkg.com/sha3/-/sha3-2.1.3.tgz#ab05b841b2bce347765db31f57fe2a3134b9fb48"
6348+
integrity sha512-Io53D4o9qOmf3Ow9p/DoGLQiQHhtuR0ulbyambvRSG+OX5yXExk2yYfvjHtb7AtOyk6K6+sPeK/qaowWc/E/GA==
6349+
dependencies:
6350+
buffer "5.6.0"
6351+
63326352
shallow-clone@^3.0.0:
63336353
version "3.0.1"
63346354
resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
@@ -7334,6 +7354,14 @@ void-elements@^2.0.1:
73347354
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
73357355
integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=
73367356

7357+
vsf-utilities@^1.0.1:
7358+
version "1.0.1"
7359+
resolved "https://registry.yarnpkg.com/vsf-utilities/-/vsf-utilities-1.0.1.tgz#b6893814280168e5f075465340e596d8b0a6f291"
7360+
integrity sha512-/A9qoDGhcis2dWd2dB1Y0gnRQC6QrQJfW4wNBed4J60w/5ur2K3MHCHKTcKFNUYjyK4CVFpBCA/6D0FOijXmYw==
7361+
dependencies:
7362+
lodash "^4.17.19"
7363+
sha3 "^2.1.3"
7364+
73377365
vxx@^1.2.0:
73387366
version "1.2.2"
73397367
resolved "https://registry.yarnpkg.com/vxx/-/vxx-1.2.2.tgz#741fb51c6f11d3383da6f9b92018a5d7ba807611"

0 commit comments

Comments
 (0)