# Google Cloud Retail V2 Client - Class CreateProductRequest (2.5.3)

2.5.3 (latest) 2.5.2 2.4.0 2.3.1 2.2.1 2.1.3 2.0.0 1.7.0 1.6.4 1.5.0 1.4.2 1.3.1 1.2.1 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Retail V2 Client class CreateProductRequest.

Request message for
[ProductService.CreateProduct](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.ProductServiceClient#_Google_Cloud_Retail_V2_Client_ProductServiceClient__createProduct__)
method.

Generated from protobuf message `google.cloud.retail.v2.CreateProductRequest`

## Namespace

Google \\ Cloud \\ Retail \\ V2

## Methods

### __construct

Constructor.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `mixed` |

### getParent

Required. The parent catalog resource name, such as
`projects/*/locations/global/catalogs/default_catalog/branches/default_branch`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setParent

Required. The parent catalog resource name, such as
`projects/*/locations/global/catalogs/default_catalog/branches/default_branch`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getProduct

Required. The [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product) to create.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product|null` |   |

### hasProduct

### clearProduct

### setProduct

Required. The [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product) to create.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getProductId

Required. The ID to use for the [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product),
which will become the final component of the
[Product.name](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product#_Google_Cloud_Retail_V2_Product__getName__).

If the caller does not have permission to create the
[Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product), regardless of whether or not it
exists, a PERMISSION_DENIED error is returned.
This field must be unique among all
[Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product)s with the same
[parent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CreateProductRequest#_Google_Cloud_Retail_V2_CreateProductRequest__getParent__). Otherwise, an
ALREADY_EXISTS error is returned.
This field must be a UTF-8 encoded string with a length limit of 128
characters. Otherwise, an INVALID_ARGUMENT error is returned.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setProductId

Required. The ID to use for the [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product),
which will become the final component of the
[Product.name](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product#_Google_Cloud_Retail_V2_Product__getName__).

If the caller does not have permission to create the
[Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product), regardless of whether or not it
exists, a PERMISSION_DENIED error is returned.
This field must be unique among all
[Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product)s with the same
[parent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CreateProductRequest#_Google_Cloud_Retail_V2_CreateProductRequest__getParent__). Otherwise, an
ALREADY_EXISTS error is returned.
This field must be a UTF-8 encoded string with a length limit of 128
characters. Otherwise, an INVALID_ARGUMENT error is returned.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### static::build

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `string` Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. Please see ProductServiceClient::branchName() for help formatting this field. |
| `product` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product` Required. The [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product) to create. |
| `productId` | `string` Required. The ID to use for the [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product), which will become the final component of the [Product.name](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product#_Google_Cloud_Retail_V2_Product__getName__). If the caller does not have permission to create the [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product), regardless of whether or not it exists, a PERMISSION_DENIED error is returned. This field must be unique among all [Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product)s with the same [parent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CreateProductRequest#_Google_Cloud_Retail_V2_CreateProductRequest__getParent__). Otherwise, an ALREADY_EXISTS error is returned. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CreateProductRequest` |   |