@@ -36,12 +36,69 @@ function exec(cmd, args, opts) {
36
36
} ) ;
37
37
38
38
child . on ( 'error' , ( error ) => {
39
- console . error ( errror )
39
+ console . error ( error )
40
40
reject ( error )
41
41
} ) ;
42
42
} )
43
43
}
44
44
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
+
45
102
program
46
103
. command ( 'import' )
47
104
. option ( '--store-code <storeCode>' , 'storeCode in multistore setup' , null )
0 commit comments