Got questions? Leave your message here or Schedule a quick call with our manager now

How to work with categories?

Categories API methods allow you to manage categories in the store. It is possible to:

  • Create - add categories
  • Read - retrieve list, info, find
  • Update - update
  • Delete - delete

Run category.add method, to add customers to the store, and provide all necessary parameters.

public function apiAdd($params)
{
  $params = array(
    'name' => 'Shoes'
  );

  return $api->request('category.add', $params);
}

If you want to update the category, call category.list method to get category id.

public function apiList($params)
{
  $params = array(
    'start'  => 2,
    'count'  => 2,
  );
  
  return $api->request('category.list', $params);
}

When you get your category id, you are able to perform category.update method.

public function apiUpdate($params)
{
  $params = array(
    'id'         => 20,
    'avail'      => 'false',
    'meta_title' => 'meta title for category'
  );
    
  return $api->request('category.update', $params);
}

If you want to assign your product to some category, simply call product.list method and category.list method to get product id and category id.

After that, run category.assign method.

public function apiAssign($params)
{
  $params = array(
    'product_id'     => 69,
    'category_id'    => 20,
  );
    
  return $api->request('category.assign', $params);
}

For more methods jump into documentation.

Posted in: Getting Started