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

A rule is a condition-action pair

- A condition defines when a rule is to be triggered.

- An action specifies what occurs on that trigger.
  Currently rules only work for [controls](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Control) with
  [SOLUTION_TYPE_SEARCH](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SolutionType#_Google_Cloud_Retail_V2_SolutionType__SOLUTION_TYPE_SEARCH).

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

## Namespace

Google \\ Cloud \\ Retail \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ boost_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.BoostAction` A boost action. |
| `↳ redirect_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.RedirectAction` Redirects a shopper to a specific page. |
| `↳ oneway_synonyms_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.OnewaySynonymsAction` Treats specific term as a synonym with a group of terms. Group of terms will not be treated as synonyms with the specific term. |
| `↳ do_not_associate_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.DoNotAssociateAction` Prevents term from being associated with other terms. |
| `↳ replacement_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.ReplacementAction` Replaces specific terms in the query. |
| `↳ ignore_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.IgnoreAction` Ignores specific terms from query during search. |
| `↳ filter_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.FilterAction` Filters results. |
| `↳ twoway_synonyms_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.TwowaySynonymsAction` Treats a set of terms as synonyms of one another. |
| `↳ force_return_facet_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.ForceReturnFacetAction` Force returns an attribute as a facet in the request. |
| `↳ remove_facet_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.RemoveFacetAction` Remove an attribute as a facet in the request (if present). |
| `↳ pin_action` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.PinAction` Pins one or more specified products to a specific position in the results. |
| `↳ condition` | `https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition` Required. The condition that triggers the rule. If the condition is empty, the rule will always apply. |

### getBoostAction

A boost action.

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

### hasBoostAction

### setBoostAction

A boost action.

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

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

### getRedirectAction

Redirects a shopper to a specific page.

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

### hasRedirectAction

### setRedirectAction

Redirects a shopper to a specific page.

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

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

### getOnewaySynonymsAction

Treats specific term as a synonym with a group of terms.

Group of terms will not be treated as synonyms with the specific term.

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

### hasOnewaySynonymsAction

### setOnewaySynonymsAction

Treats specific term as a synonym with a group of terms.

Group of terms will not be treated as synonyms with the specific term.

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

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

### getDoNotAssociateAction

Prevents term from being associated with other terms.

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

### hasDoNotAssociateAction

### setDoNotAssociateAction

Prevents term from being associated with other terms.

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

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

### getReplacementAction

Replaces specific terms in the query.

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

### hasReplacementAction

### setReplacementAction

Replaces specific terms in the query.

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

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

### getIgnoreAction

Ignores specific terms from query during search.

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

### hasIgnoreAction

### setIgnoreAction

Ignores specific terms from query during search.

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

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

### getFilterAction

Filters results.

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

### hasFilterAction

### setFilterAction

Filters results.

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

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

### getTwowaySynonymsAction

Treats a set of terms as synonyms of one another.

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

### hasTwowaySynonymsAction

### setTwowaySynonymsAction

Treats a set of terms as synonyms of one another.

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

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

### getForceReturnFacetAction

Force returns an attribute as a facet in the request.

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

### hasForceReturnFacetAction

### setForceReturnFacetAction

Force returns an attribute as a facet in the request.

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

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

### getRemoveFacetAction

Remove an attribute as a facet in the request (if present).

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

### hasRemoveFacetAction

### setRemoveFacetAction

Remove an attribute as a facet in the request (if present).

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

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

### getPinAction

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

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

### hasPinAction

### setPinAction

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

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

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

### getCondition

Required. The condition that triggers the rule.

If the condition is empty, the rule will always apply.

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

### hasCondition

### clearCondition

### setCondition

Required. The condition that triggers the rule.

If the condition is empty, the rule will always apply.

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

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

### getAction

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