Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hiswe/gulp-dump-shopify
Dump some datas from a Shopify shop
https://github.com/hiswe/gulp-dump-shopify
Last synced: 30 days ago
JSON representation
Dump some datas from a Shopify shop
- Host: GitHub
- URL: https://github.com/hiswe/gulp-dump-shopify
- Owner: Hiswe
- License: wtfpl
- Created: 2015-09-19T11:38:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-06T16:12:11.000Z (almost 6 years ago)
- Last Synced: 2024-11-28T22:18:05.376Z (30 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/gulp-dump-shopify
- Size: 87.9 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gulp dump shopify
The purpose of this plugin is to grab some datas from [Shopify API](https://docs.shopify.com/api) and to consolidate them in a single JSON file.
Also this file will try to match as much as possible [Shopify's Objects](https://docs.shopify.com/themes/liquid-documentation/objects)
The main use case should be to render a static integration with some datas similar to Shopify's one.
## Install
```
npm install gulp-dump-shopify --save-dev
```## Use
You will need some credentials from Shopify (see [creating-a-private-app](https://docs.shopify.com/api/authentication/creating-a-private-app))
```js
var gulp = require('gulp');
var dumpShopify = require('gulp-dump-shopify');gulp.task('dump', function () {
return dumpShopify({
domain: 'https://your-domain.myshopify.com',
apikey: '32characterswithnumbersandletter',
password: '32characterswithnumbersandletter',
})
.pipe(gulp.dest('dump'));
});
```### Additional options
*gulp-dump-shopify* can take a `debug` option. If set to `true`, it will also write all results from api calls, and split the dump file in a general, collections & products files.
### Handle collections & products references
To avoid circular references in JSON, all references of products and collections are only made with *ids*.
You should replace them with “real” products/collections in order to be closer of Shopify's Object.
```js
var shopify = require('dump/mockup-shopify.json');
var collections = shopify.collections;
var products = shopify.products;// reference products in collections
function getProduct(productId) {
return products[productId];
}
for (let collectionName in collections) {
let coll = collections[collectionName];
coll.products = coll.products.map(getProduct);
}// reference collections in products
function getCollection(collectionId) {
return collections[collectionId];
}
for (let productId in products) {
let prod = products[productId];
prod.collections = prod.collections.map(getCollection);
}// feed those datas to some templates
// …```