MasterProducts (Common Products for Vendors)

MasterProducts are common products that vendors can sell. This entity is added by the Common Products for Vendors add-on that is available in Multi-Vendor.

Get Common Products

To get a list of common products, send a GET request to /api/master_products/:

GET /api/master_products/

The number of the returned products can be changed by the items_per_page parameter. For example:

GET /api/master_products/?items_per_page=100

The default number is defined by the Elements per page setting in the Admin panel on the Settings → General → Appearance page.

To refer to all products of a particular Category send a GET request to /api/categories/:id/master_products/:

GET /api/categories/166/master_products/

Pagination, Sorting and Filtering

Pagination, sorting, and filtering parameters are inherited from Products.

The Common Products for Vendors add-on adds the show_master_products_only filtering parameter with true or false value, available via Products API.

The true value will return only common products in the response, while the false will return only products offered by vendors.

Examples

  • GET /api/master_products?sort_by=price&sort_order=asc

    Response is an array of all common products sorted by price in an ascending order.

  • GET /api/master_products?page=5&items_per_page=20

    Response is an array of 20 common products from the 5th Products page.

  • GET /api/master_products/310

    Response is the data of a common product with the id 310.

Response Format

Field name Values Description
master_product_id integer ID of a common product to which the product belongs
master_product_status
A
D
H
The status of a common product to which the product belongs:
A for Active
D for Disabled
H for Hidden
master_product_offers_count integer The current number of product offers that the common product has

Create a Common Product

To create a new common product, send a POST request to /api/master_products/ with required fields in JSON: product, price.

Example JSON

{
   "product": "Common product name",
   "price": "100"
}
``

This request creates a common product with minimum required details: a name, and a price.

Response Format

  • The product has been created successfully: HTTP/1.1 201 Created and the JSON with the new product_id. For example:

    {
        "product_id": 310
    }
    
  • The product couldn’t be created: HTTP/1.1 400 Bad Request.

Update a Common Product

To update an existing common product, send the PUT request to /api/master_products/:id/. For example:

PUT /api/master_product/310

A product has a number of properties, represented by fields.

Example JSON

{
         "product_code": "12345",
         "price": "99.90",
         "list_price": "110.00",
         "category_ids": [223]
}

This request updates the Product Code, the List Price, the Price, and the Category of the particular Common Product.

Response Format

  • The product has been updated successfully: HTTP/1.1 200 OK and JSON with product_id.
  • The product couldn’t be updated because it is not common: HTTP/1.1 400 Bad Request: Product was found but it is not common product. Please specify common product ID.

Delete a Product

To delete a product, send a DELETE request to /api/master_products/:id. For example:

DELETE /api/master_products/310/

This request will delete the product with product_id=310.

Response Format

  • The product has been deleted successfully: HTTP/1.1 204 No Content.
  • The product could not be deleted or does not exist: HTTP/1.1 400 Bad Request.

Big CS-Cart Update is Here Experience the New Admin Panel with Dark Theme