Methods/Products

Methods/Products

Source:

Methods for Products. Run these methods using Meteor.call().

Methods

(static) products/removeMetaFields(productId, metafields, type) → {Number}

update product metafield

Source:
Parameters:
Name Type Description
productId String

productId

metafields Object

metadata object to remove

type Object

optional product type for schema selection

Returns:

collection update result

Type
Number

(static) products/removeProductTag(productId, tagId) → {String}

method to remove tag from product

Source:
Parameters:
Name Type Description
productId String

productId

tagId String

tagId

Returns:

return update result

Type
String

(static) products/setHandle(productId) → {String}

copy of "products/setHandleTag", but without tag

Source:
Parameters:
Name Type Description
productId String

productId

Returns:

handle - product handle

Type
String

(static) products/setHandleTag(productId, tagId) → {String}

set or toggle product handle

Source:
Parameters:
Name Type Description
productId String

productId

tagId String

tagId

Returns:

return update result

Type
String

(static) products/toggleVisibility(productId) → {Boolean}

publish (visibility) of product

Source:
To Do:
  • hook into publishing flow
Parameters:
Name Type Description
productId String

productId

Returns:

product.isVisible

Type
Boolean

(static) products/updateMetaFields(productId, updatedMeta, meta) → {Number}

update product metafield

Source:
To Do:
  • should this method works for variants also?
Parameters:
Name Type Description
productId String

productId

updatedMeta Object

update object with metadata

meta Object | Number | undefined | null

current meta object, or a number index

Returns:

collection update result

Type
Number

(static) products/updateProductField(_id, field, value) → {Number}

update single product or variant field

Source:
To Do:
  • rename it to something like "products/updateField" to reflect
  • we need to know which type of entity field belongs. For that we could do something like: const type = Products.findOne(_id).type or transmit type as param if it possible latest changes. its used for products and variants
Parameters:
Name Type Description
_id String

product._id or variant._id to update

field String

key to update

value *

update property value

Returns:

returns update result

Type
Number

(static) products/updateProductTags(productId, tagName, tagId) → {Number}

method to insert or update tag with hierarchy

Source:
Parameters:
Name Type Description
productId String

productId

tagName String

tagName

tagId String

tagId

Returns:

return result

Type
Number

(static) products/updateVariantsPosition(sortedVariantIds, shopId) → {Number}

updates top level variant position index

.

Source:
Since:
  • 0.11.0

updates top level variant position index

Parameters:
Name Type Description
sortedVariantIds Array

array of top level variant _ids

shopId String

The ID of the shop that owns all variants being sorted

Returns:

Products.update result

Type
Number