vuestorefront / mage2vuestorefront

Magento to Vue-storefront datapump - synchronizes Products, Categories and Product-to-category links between your Magento2 API and NoSQL database of vue-storefront

Home Page:http://vuestorefront.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delta indexer not working with multiple stores

Cyclonecode opened this issue · comments

It seems like the delta indexer does not work with multiple stores.
If I update a product in my magento backend and then run the following:

#!/bin/bash

TIME_TO_EXIT=1000
MAGENTO_STORE_ID=1
MAGENTO_CURRENCY_CODE=USD
INDEX_NAME=vue_storefront_catalog
MAGENTO_ACCESS_TOKEN_SECRET="<ACCESS_TOKEN_SECRET>"
MAGENTO_ACCESS_TOKEN="<ACCESS_TOKEN>"
MAGENTO_CONSUMER_SECRET="<CONSUMER_SECRET>"
MAGENTO_CONSUMER_KEY="<CONSUMER_KEY>"
MAGENTO_URL="http://<MAGENTO_URL>/rest/"

export TIME_TO_EXIT MAGENTO_STORE_ID INDEX_NAME MAGENTO_ACCESS_TOKEN MAGENTO_ACCESS_TOKEN_SECRET MAGENTO_CONSUMER_SECRET MAGENTO_CONSUMER_KEY MAGENTO_URL

cd mage2vuestorefront/src

#Ansible: delta_indexer_se
export MAGENTO_CURRENCY_CODE=SEK MAGENTO_URL=http://<MAGENTO_URL>/rest/ INDEX_NAME=vue_storefront_catalog MAGENTO_STORE_ID=1 && node --harmony cli.js productsdelta --partitions=1
#Ansible: delta_indexer_dk
export MAGENTO_CURRENCY_CODE=DKK MAGENTO_URL=http://<MAGENTO_URL>/rest/dk INDEX_NAME=vue_storefront_catalog_dk MAGENTO_STORE_ID=2 && node --harmony cli.js productsdelta --partitions=1
#Ansible: delta_indexer_eu
export MAGENTO_CURRENCY_CODE=EUR MAGENTO_URL=http://<MAGENTO_URL>/rest/eu INDEX_NAME=vue_storefront_catalog_eu MAGENTO_STORE_ID=3 && node --harmony cli.js productsdelta --partitions=1
#Ansible: delta_indexer_fi
export MAGENTO_CURRENCY_CODE=EUR MAGENTO_URL=http://<MAGENTO_URL>/rest/fi INDEX_NAME=vue_storefront_catalog_fi MAGENTO_STORE_ID=4 && node --harmony cli.js productsdelta --partitions=1
#Ansible: delta_indexer_global
export MAGENTO_CURRENCY_CODE=USD MAGENTO_URL=http://<MAGENTO_URL>/rest/global INDEX_NAME=vue_storefront_catalog_global MAGENTO_STORE_ID=5 && node --harmony cli.js productsdelta --partitions=1
#Ansible: delta_indexer_no
export MAGENTO_CURRENCY_CODE=NOK MAGENTO_URL=http://<MAGENTO_URL>/rest/no INDEX_NAME=vue_storefront_catalog_no MAGENTO_STORE_ID=6 && node --harmony cli.js productsdelta --partitions=1

Only the first node --harmony cli.js productsdelta --partitions=1 will actually do something, while the others will return No records to process!?

If change the order of the above calls, still just the first one will actually update my index with new data?

Is this a bug or am I doing something wrong here?

I belive we need to modify the https://github.com/DivanteLtd/mage2vuestorefront/blob/e1b7a69ad3111f2121d6d3c6c705d76d8a5fb2ac/src/cli.js#L383 to have a differend INDEX_META_PATH per index name. Otherwise the last-index timestamp is being used from after the previous import operation,

Just to visualize the process:

load delta timestamp from INDEX_META_PATH = 0
import SEK - takes 15s
save current timestamp to INDEX_META_PATH

load delta timestamp from INDEX_META_PATH = 15 (should be 0)
import UK
save current timestamp to INDEX_META_PATH

...

This is resolved by #50