This will synchronize WooCommerce data with NetPS Plant Finder data. The script requires a few things to operate and is intended to run on initial item setup. It can run multiple times though because it only looks for uncategorized products in WooCommerce.
- PHP 7.4 or higher
- Composer
- WooCommerce API
- Google Sheets API for accessing your lookup table
- Net PS CSV downloaded and placed in the root folder
I'm not going to explain installs of PHP, Composer, or Net PS download. This should be easily found online if you are this far.
- You will need to copy the
.env.example
file to.env
and fill out your information as required. - Run
composer install
to get all required vendor scripts - You should have Google's
credentials.json
placed in the root folder - Place
netps.csv
data in the root folder - Run
php index.php
and follow any prompts for Google or keys
This script performs the following in order:
- Find all categories in WooCommerce
- Find the category that matches
uncategorized
in WooCommerce - Find all products that are published in the
uncategorized
category - Loop through products and lookup SKU in Google Sheet to find NetPS #
- Stores NetPS ID and Product ID
- Get NetPS data
- Fetch NetPS category, description, photo that matches WooCommerce Product
- Create WooCommerce category if needed.
- Update product and categories
- Generate report of what changed
Chris Smith - @cgsmith105