woocommerce2vuestorefront indexer is standalone application designed to feed VSF's catalog models with data right from WooCommerce.
Sign up for a demo at https://vuestorefront.io/ (Vue Storefront integrated with Pimcore, Magento2, WooCommerce ...).
You should install Vue Storefront prior to use this indexer (which is feeding the Vue Storefront datbase). Read the installation guide.
This project provides an indexer for WooCommerce data structures
The module is a standalone application that:
- does process and index: attributes, products and categories to Elasticsearch Search Engine (VSF Catalog model)
- Node.js 8.2 or higher
- Running Elasticsearch 5.6+ (It's contained in whole VSF API stack)
- Running WooCommerce (tested on version 3.5.3)
- Make sure you have configured REST API properly, and the REST API is publicly accessible
- Generate consumer key and consumer secret in advenced tab in WooCommerce settings (read only permissions are sufficient)
- Having already installed VSF API, you should build an index with proper mapping for each type, you can achive this by
running at the VSF API project's root dir:
nodejs scripts/db.js new
In config.js
there is a woo section when you should adjust some data, i.e. keys for REST requests:
woo: {
api: {
host: 'localhost',
protocol: 'http',
auth: {
consumer_key: "",
consumer_secret: "",
version: "v3"
}
}
},
notice that version should stay the same.
In db
section contained in config.js
file you should adjust some info about ES:
db: {
host: 'localhost',
port: 9200,
driver: 'elasticsearch',
url: 'http://localhost:9200',
indexName: 'vue_storefront_catalog'
},
notice that indexName can be changed but it should stay consistent with VSF configuration.
Please execute indexers one by one with:
- attributes:
nodejs cli.js attributes
- categories:
nodejs cli.js categories
- products:
nodejs cli.js products
and that's it.
- docker
- docker-compose
To simplify the development process You may want to use one of existing tools, for instance: ready-to-use docker images and wp-cli
:
- run containers by using
docker-compose.dev.yml
located indev/docker/
subdirectory:docker-compose -f docker-compose.dev.yml up
it's recommended to run this command being inside
docker
dir, because of docker's networking naming conventions which will be used in further steps
- install Wordpress fresh instance:
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp core install --url="localhost" --title="VSFvsWoo" --admin_user="admin" --admin_email="[email protected]" --admin_password=admin
notice what parameters should be passed with command above: network and volumes-from should cover names set in docker-compose.dev.yml it creates a new wordpress's instance available on
localhost
and with credentialsadmin
/admin
-
install woocommerce plugin via wp-cli:
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp plugin install woocommerce --activate
-
add some attributes and options, running:
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp wc product_attribute create --name=Size --type=options --user=admin
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp wc product_attribute_term create 1 --name=XS --user=admin
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp wc product_attribute_term create 1 --name=L --user=admin
wp-cli command
wc product_attribute_term create
requires as a first input an ID of attribute created at first step (in this case1
)
- add some products via cli or manually in wp-admin panel:
docker run -it --rm --volumes-from vsf_woo --network docker_default wordpress:cli wp wc product create --name="Vue T-Shirt L" --type=simple --sku=VUE/T-shirt/L --regular_price=200 --user=admin --sale_price=150 --stock_quantity=94 --in_stock=true
always pay attention to the arguments provided in commands above which can vary depending on WP/WooCommerce current state.
This module has been initially created by Divante's team:
- Maciej Kucmus - @mkucmus
If You have any questions regarding this project feel free to contact us:
woocommerce2vuestorefront source code is completely free and released under the MIT License.