Categories

(ms.categories)

It contains all the categories that are required for a specific site.



Fields

ValueDescription
name   
Type: string
Required
Name of the category.
Women's Apparels
alias   
Type: string
Aliases are the unique category URL on storefront. It is automatically generated from the name of brand.
women-apparels
description   
Type: string
Brief description about the category.
Trendy apparels for women.
images   
Type: array
Images for the category.
{
  "images": [
  {
    "image": "sample-image-woman.png",
    "caption": "Women Apparels"
  }
 ]
}
image
Type: file
Required
Single image related to the category.
sample-image-women.png
caption
Type: string
This field holds text which acts as title of image on storefront.
Women Apparels
parent   
Type: string
Parent category (if any) of the category.
Apparels
count   
Type: integer
It stores the count of products of a category.
SEO   
Type: object
SEO contains data that affects the online visibility of the category on search engine.
{ 
  "SEO": {
        "title": "Trendy women apparels at 50% off",
        "description": "Buy trendy women apparels at flat 50% off. Dresses, tops, skirts, jeans. Same day delivery. No shipping cost",
        "keywords": "trendy apparels, women apparels"
    }
}
title
Type: string
The title of the category to specify a custom title for the category page for SEO.
Trendy women apparels at 50% off
description
Type: string
Specify a custom meta description for the category page for SEO.
Buy trendy women apparels at flat 50% off. Dresses, tops, skirts, jeans. Same day delivery. No shipping cost.
keywords
Type: string
Specify the keywords to specify custom meta keywords for the category page for SEO.
trendy apparels, women apparels
canonical_url
Type: string
The canonical URL is used to declare a single page as its source or for duplicate pages to reference their source/originating page.
sitemap_priority
Type: string
Sitemap priority defines the priority of the particular page in your store.
0.3
metafield_sets   
Type: array
Metafields to be used in case you need extra fields in categories.
publish   
Type: string
Enabling the flag makes the category visible on storefront.
1
default_sort_order   
Type: string
Order by which products of the category will be sorted.
By date: Newest to oldest
widget   
Type: string

Commands (Endpoints)

POST /api/1/entity/ms.categories   
This command is used to add a new category

Examples

add a new category

Request
  data : {
            name: 'Children Wear',
            alias: "Children-Wear",
            description: 'A place where you find the different types of fashionable dress for children',
            publish: 1,
                }
Response
{ status: 200,
  data: { _id: '5d4d5393b6455f39d99da051' },
  messages: 
   [ { name: 'ms.entity.categories.add',
       level: 'success',
       key: 'ms.entity.categories.add' } ] }

add a subcategory

Request
{
    "data": {
        "name": "raymonds",
        "alias": "raymonds",
        "description": "<p><span>The more powerful the customer&rsquo;s fantasy of owning the product, the more likely they are to buy it. Therefore, I like to think of&nbsp;</span>product descriptions as storytelling and psychology<span>, incorporating the elements of both prose writing and journalism. A &ldquo;good&rdquo; product description will not do. Competition is getting too fierce. It must be great!</span></p>",
        "parent" : "5d789e7acbe1ee658c8b193a",
        "publish": 1
    }
}
Response
{
    "fileBaseUrl": "https://cdn.storehippo.com/s/57aaca10964eb5eb1362cb19/",
    "data": {
        "_id": "5d7b36c95c88b60315e7f1c8"
    },
    "messages": [
        {
            "name": "ms.entity.categories.add",
            "level": "success",
            "key": "ms.entity.categories.add"
        }
    ]
}
PUT /api/1/entity/ms.categories/{resource_id}   
This command is used to update the existing category

Examples

edit

Request
 {
            recordId  : "5d4d57acb6455f39d99da5f8",
            data : {
                name: 'Men Wear',
                alias: 'Men-Wear'
            },
            "version": 1,
            command : 'edit'
        }
Response
 { status: 200,
  data: 'updated successfully',
  messages: 
   [ { name: 'ms.entity.categories.edit',
       level: 'success',
       key: 'ms.entity.categories.edit' } ] }

update an existing category

Request
{
    "data": {
        "name": "new raymond",
        "alias": "new-raymond",
        "description": "<p><span>The more powerful the customer&rsquo;s fantasy of owning the product, the more likely they are to buy it. Therefore, I like to think of&nbsp;</span>product descriptions as storytelling and psychology<span>, incorporating the elements of both prose writing and journalism. A &ldquo;good&rdquo; product description will not do. Competition is getting too fierce. It must be great!</span></p>",
        "parent" : "5d789e7acbe1ee658c8b193a",
        "publish": 1
    }
}
Response
{
    "fileBaseUrl": "https://cdn.storehippo.com/s/57aaca10964eb5eb1362cb19/",
    "data": "updated successfully",
    "messages": [
        {
            "name": "ms.entity.categories.edit",
            "level": "success",
            "key": "ms.entity.categories.edit"
        }
    ]
}
GET /api/1/entity/ms.categories/{resource_id}   
Retrieves a single categorie
GET /api/1/entity/ms.categories   
Retrieves a list of categories
skipResolveTask