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

Commit 8854adc

Browse files
authored
Merge pull request #146 from Cyclonecode/feature/mage2vs-delta-indexer
Add delta indexer
2 parents 7344521 + 0455c0f commit 8854adc

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
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
-------

scripts/mage2vs.js

Lines changed: 58 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)

0 commit comments

Comments
 (0)