Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor Shopify API: Post metafield to collection by collection ID

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).

like image 892
elzi Avatar asked May 26 '15 21:05

elzi


People also ask

How do I retrieve a MetaField with the storefront API?

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.

What is _ID in each document in Meteor?

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.

How do I Turn Off autopublish in Meteor?

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.

How do I create a collection in Mongo Meteor?

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.


1 Answers

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"
});
like image 65
aquint Avatar answered Nov 04 '22 01:11

aquint