# Google Cloud Retail V2 Client - Class PinAction (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 PinAction.

Pins one or more specified products to a specific position in the
results.

- Rule Condition: Must specify non-empty [Condition.query_terms](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition#_Google_Cloud_Retail_V2_Condition__getQueryTerms__) (for search only) or [Condition.page_categories](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition#_Google_Cloud_Retail_V2_Condition__getPageCategories__) (for browse only), but can't specify both.
- Action Input: mapping of `[pin_position, product_id]` pairs (pin position uses 1-based indexing).
- Action Result: Will pin products with matching ids to the position specified in the final result order. Example: Suppose the query is `shoes`, the [Condition.query_terms](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition#_Google_Cloud_Retail_V2_Condition__getQueryTerms__) is `shoes` and the pin_map has `{1, "pid1"}`, then product with `pid1` will be pinned to the top position in the final results. If multiple PinActions are matched to a single request the actions will be processed from most to least recently updated. Pins to positions larger than the max allowed page size of 120 are not allowed.

Generated from protobuf message `google.cloud.retail.v2.Rule.PinAction`

## Namespace

Google \\ Cloud \\ Retail \\ V2 \\ Rule

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ pin_map` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` Required. A map of positions to product_ids. Partial matches per action are allowed, if a certain position in the map is already filled that `[position, product_id]` pair will be ignored but the rest may still be applied. This case will only occur if multiple pin actions are matched to a single request, as the map guarantees that pin positions are unique within the same action. Duplicate product_ids are not permitted within a single pin map. The max size of this map is 120, equivalent to the max [request page size](https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#request-body). |

### getPinMap

Required. A map of positions to product_ids.

Partial matches per action are allowed, if a certain position in the map
is already filled that `[position, product_id]` pair will be ignored
but the rest may still be applied. This case will only occur if multiple
pin actions are matched to a single request, as the map guarantees that
pin positions are unique within the same action.
Duplicate product_ids are not permitted within a single pin map.
The max size of this map is 120, equivalent to the max [request page
size](https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#request-body).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setPinMap

Required. A map of positions to product_ids.

Partial matches per action are allowed, if a certain position in the map
is already filled that `[position, product_id]` pair will be ignored
but the rest may still be applied. This case will only occur if multiple
pin actions are matched to a single request, as the map guarantees that
pin positions are unique within the same action.
Duplicate product_ids are not permitted within a single pin map.
The max size of this map is 120, equivalent to the max [request page
size](https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#request-body).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

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