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

Commit 3c9ed0e

Browse files
authored
Merge pull request #148 from DivanteLtd/develop
v1.6.0
2 parents 220bcb9 + 1596b29 commit 3c9ed0e

28 files changed

+7510
-13368
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ You can run the following command to execute the full import:
131131
``bash
132132
yarn mage2vs import --store-code=de
133133
```
134+
135+
## Executing delta indexer
136+
137+
You can use the following command to run a delta indexer for a specific storeview:
138+
139+
```
140+
yarn mage2vs productsdelta --store-code=de
141+
```
134142
135143
License
136144
-------

config/default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"port": 8080,
55
"searchEngine": "elasticsearch"
66
},
7+
"orders": {
8+
"useServerQueue": false
9+
},
710
"elasticsearch": {
811
"host": "localhost",
912
"port": 9200,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

config/elastic.schema.block.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"properties": {
3+
"id": {
4+
"type": "long"
5+
},
6+
"identifier": {
7+
"type": "keyword"
8+
},
9+
"creation_time": {
10+
"type": "date",
11+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
12+
},
13+
"update_time": {
14+
"type": "date",
15+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
16+
}
17+
}
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

config/elastic.schema.page.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"properties": {
3+
"id": {
4+
"type": "long"
5+
},
6+
"identifier": {
7+
"type": "keyword"
8+
},
9+
"creation_time": {
10+
"type": "date",
11+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
12+
},
13+
"update_time": {
14+
"type": "date",
15+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
16+
}
17+
}
18+
}

config/elastic.schema.product.extension.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"position": {"type": "integer"},
44
"tax_class_id": {"type": "integer"},
55
"required_options": {"type": "integer"},
6-
"has_options": {"type": "integer"}
6+
"has_options": {"type": "integer"} ,
7+
"Size_options": {"type": "keyword"},
8+
"Color_options": {"type": "keyword"}
79
}
810
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"ajv": "^6.4.0",
5555
"body-parser": "^1.18.2",
5656
"bodybuilder": "2.2.13",
57-
"commander": "^2.18.0",
57+
"commander": "^2.19.0",
5858
"compression": "^1.7.2",
5959
"config": "^1.30.0",
6060
"cors": "^2.8.4",

scripts/kue.js

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
1-
import CommandRouter from 'command-router'
2-
1+
const program = require('commander')
32
const config = require('config').redis
43
const kue = require('kue')
54

6-
const cli = CommandRouter()
7-
8-
cli.option({
9-
name: 'port',
10-
alias: 'p',
11-
default: 3000,
12-
type: Number
13-
})
14-
15-
cli.option({
16-
name: 'prefix',
17-
alias: 'q',
18-
default: 'q',
19-
type: String
20-
})
21-
22-
cli.command('dashboard', () => {
23-
24-
kue.createQueue({
25-
redis: {
26-
host: config.host,
27-
port: config.port,
28-
db: config.db
29-
},
30-
prefix: cli.options.prefix
31-
})
32-
33-
kue.app.listen(cli.options.port)
34-
})
35-
36-
cli.on('notfound', (action) => {
37-
console.error(`I don't know how to: ${action}`)
38-
process.exit(1)
39-
})
5+
program
6+
.command('dashboard')
7+
.option('-p|--port <port>', 'port on which to run kue dashboard', 3000)
8+
.option('-q|--prefix <prefix>', 'prefix', 'q')
9+
.action((cmd) => {
10+
kue.createQueue({
11+
redis: {
12+
host: config.host,
13+
port: config.port,
14+
db: config.db
15+
},
16+
prefix: cmd.prefix
17+
})
18+
19+
kue.app.listen(cmd.port)
20+
});
21+
22+
program
23+
.on('command:*', () => {
24+
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
25+
process.exit(1);
26+
});
27+
28+
program
29+
.parse(process.argv)
4030

4131
process.on('unhandledRejection', (reason, p) => {
42-
console.log(`Unhandled Rejection at: Promise ${p}, reason: ${reason}`)
43-
})
44-
45-
process.on('uncaughtException', function(exception) {
46-
console.log(exception)
32+
console.error(`Unhandled Rejection at: Promise ${p}, reason: ${reason}`)
33+
// application specific logging, throwing an error, or other logic here
4734
})
4835

49-
cli.parse(process.argv)
36+
process.on('uncaughtException', function (exception) {
37+
console.error(exception) // to see your exception details in the console
38+
// if you are on production, maybe you can send the exception details to your
39+
// email as well ?
40+
})

scripts/mage2vs.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,69 @@ function exec(cmd, args, opts) {
3636
});
3737

3838
child.on('error', (error) => {
39-
console.error(errror)
39+
console.error(error)
4040
reject(error)
4141
});
4242
})
4343
}
4444

45+
program
46+
.command('productsdelta')
47+
.option('--store-code <storeCode>', 'storeCode in multistore setup', null)
48+
.option('--adapter <adapter>', 'name of the adapter', 'magento')
49+
.option('--partitions <partitions>', 'number of partitions', 1)
50+
.option('--partitionSize <partitionSize>', 'size of the partitions', 200)
51+
.option('--initQueue <initQueue>', 'use the queue', true)
52+
.option('--skus <skus>', 'comma delimited list of SKUs to fetch fresh informations from', '')
53+
.option('--removeNonExistent <removeNonExistent>', 'remove non existent products', false)
54+
.action((cmd) => {
55+
const apiConfig = multiStoreConfig(config.magento2.api, cmd.storeCode)
56+
let magentoConfig = {
57+
TIME_TO_EXIT: 2000,
58+
PRODUCTS_SPECIAL_PRICES: true,
59+
MAGENTO_CONSUMER_KEY: apiConfig.consumerKey,
60+
MAGENTO_CONSUMER_SECRET: apiConfig.consumerSecret,
61+
MAGENTO_ACCESS_TOKEN: apiConfig.accessToken,
62+
MAGENTO_ACCESS_TOKEN_SECRET: apiConfig.accessTokenSecret,
63+
MAGENTO_STORE_ID: 1,
64+
INDEX_META_PATH: '.lastIndex.json',
65+
MAGENTO_URL: apiConfig.url,
66+
REDIS_HOST: config.redis.host,
67+
REDIS_PORT: config.redis.port,
68+
INDEX_NAME: config.elasticsearch.indices[0]
69+
70+
}
71+
if (cmd.storeCode) {
72+
const storeView = config.storeViews[cmd.storeCode]
73+
if (!storeView) {
74+
console.error('Wrong storeCode provided - no such store in the config.storeViews[storeCode]', cmd.storeCode)
75+
process.exit(-1)
76+
} else {
77+
magentoConfig.INDEX_NAME = storeView.elasticsearch.index
78+
magentoConfig.INDEX_META_PATH = '.lastIndex-' + cmd.storeCode + '.json'
79+
magentoConfig.MAGENTO_STORE_ID = storeView.storeId
80+
}
81+
}
82+
83+
const env = Object.assign({}, magentoConfig, process.env) // use process env as well
84+
console.log('=== Delta indexer is about to start ===')
85+
86+
exec('node', [
87+
'--harmony',
88+
'node_modules/mage2vuestorefront/src/cli.js',
89+
'productsdelta',
90+
'--adapter=' + cmd.adapter,
91+
'--partitions=' + cmd.partitions,
92+
'--partitionSize=' + cmd.partitionSize,
93+
'--initQueue=' + cmd.initQueue,
94+
'--skus=' + cmd.skus,
95+
'--removeNonExistent=' + cmd.removeNonExistent
96+
], { env: env, shell: true }).then((res) => {
97+
98+
})
99+
100+
})
101+
45102
program
46103
.command('import')
47104
.option('--store-code <storeCode>', 'storeCode in multistore setup', null)
@@ -55,6 +112,8 @@ program
55112
MAGENTO_ACCESS_TOKEN: apiConfig.accessToken,
56113
MAGENTO_ACCESS_TOKEN_SECRET: apiConfig.accessTokenSecret,
57114
MAGENTO_URL: apiConfig.url,
115+
REDIS_HOST: config.redis.host,
116+
REDIS_PORT: config.redis.port,
58117
INDEX_NAME: config.elasticsearch.indices[0]
59118
}
60119

0 commit comments

Comments
 (0)