Using froatsnook:shopify
Trying to get the metafields for a collection. I have the collection ID. According to Shopify's API Documentation, I should be able to get metafields for a collection, but I'm not seeing the parameter for it.
Code:
getShopifyCollectionMetafields: function(collection_id) {
// GET /admin/products/#{id}/metafields.json
var meta = ShopifyAPI.getProductMetafields({id: collection_id});
console.log(meta)
}
Which returns an empty array (which makes sense, I'm trying to pass a collection ID where it expects a product ID - but not sure what to do).
After exposing metafields, you can retrieve them with the Storefront API by using the metafield field. You can retrieve a single metafield for a product or a product variant. To specify the metafield that you want to retrieve, use the namespace and key arguments.
Each document is a EJSON object. It includes an _id property whose value is unique in the collection, which Meteor will set when you first create the document.
By default, Meteor automatically publishes every document in your collection to each connected client. To turn this behavior off, remove the autopublish package, in your terminal: and instead call Meteor.publish to specify which parts of your collection should be published to which users.
Meteor stores data in collections. To get started, declare a collection with new Mongo.Collection. Constructor for a Collection The name of the collection. If null, creates an unmanaged (unsynchronized) local collection. The server connection that will manage this collection.
I believe you can specify your own calls if they aren't implemented, like so:
Shopify.API.define({
"name": "getCollectionMetafields",
"method": "GET",
"path": "/admin/custom_collections/#{id}/metafields.json",
"returns": "metafield",
"description": "Get a collection's metafields"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With