Skip to content

Commit 7ec981e

Browse files
authored
Link Product API to criteria, sort clauses, and PHP API Ref (#2521)
1 parent ac53a56 commit 7ec981e

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

docs/pim/product_api.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ description: Use PHP API to manage products in PIM, their attributes, availabili
88

99
[[= product_name =]]'s Product API provides two services for handling product information, which differ in function:
1010

11-
- `ProductServiceInterface` is used to request product data
12-
- `LocalProductServiceInterface` is used to modify products
11+
- [`ProductServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-ProductServiceInterface.html) is used to request product data
12+
- [`LocalProductServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalProductServiceInterface.html) is used to modify products
1313

1414
!!! tip "Product REST API"
1515

1616
To learn how to load products using the REST API, see [REST API reference](../api/rest_api/rest_api_reference/rest_api_reference.html#product-catalog-create-product-type).
1717

1818
### Getting product information
1919

20-
Get an individual product by using the `productService::getProduct()` method:
20+
Get an individual product by using the `ProductServiceInterface::getProduct()` method:
2121

2222
``` php
2323
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 68, 71) =]]
2424
```
2525

26-
Find multiple products with `productService::findProducts()`.
26+
Find multiple products with `ProductServiceInterface::findProducts()`.
27+
2728
Provide the method with optional filter, query or Sort Clauses.
2829

2930
``` php
3031
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 72, 82) =]]
3132
```
3233

34+
See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clauses](product_sort_clauses.md) references for more information about how to use the [`ProductQuery`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Product-ProductQuery.html) class.
35+
3336
### Modifying products
3437

3538
To create, update and delete products, use the `LocalProductServiceInterface`.
@@ -38,15 +41,15 @@ To create, update and delete products, use the `LocalProductServiceInterface`.
3841
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 93, 97) =]]
3942
```
4043

41-
To create a product, use `LocalProductService::newProductCreateStruct()`.
44+
To create a product, use `LocalProductServiceInterface::newProductCreateStruct()` to get a [`ProductCreateStruct`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-Product-ProductCreateStruct.html).
4245
Provide the method with the product type object and the main language code.
4346
You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`:
4447

4548
``` php
4649
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 83, 90) =]]
4750
```
4851

49-
To delete a product, use `LocalProductService::deleteProduct()`:
52+
To delete a product, use `LocalProductServiceInterface::deleteProduct()`:
5053

5154
``` php
5255
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 120, 121) =]]
@@ -55,7 +58,7 @@ To delete a product, use `LocalProductService::deleteProduct()`:
5558
### Product variants
5659

5760
You can access the variants of a product by using `ProductServiceInterface::findProductVariants()`.
58-
The method takes the product object and a `ProductVariantQuery` object as parameters.
61+
The method takes the product object and a [`ProductVariantQuery`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Product-ProductVariantQuery.html) object as parameters.
5962

6063
A `ProductVariantQuery` lets you define the offset and limit of the variant query.
6164
The default offset is 0, and limit is 25.
@@ -64,17 +67,17 @@ The default offset is 0, and limit is 25.
6467
[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 57, 60) =]]
6568
```
6669

67-
From a variant, you can access the attributes that are used to generate the variant
68-
by using `ProductVariant::getDiscriminatorAttributes()`.
70+
From a variant ([`ProductVariantInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-ProductVariantInterface.html)),
71+
you can access the attributes that are used to generate the variant by using `ProductVariantInterface::getDiscriminatorAttributes()`.
6972

7073
``` php
7174
[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 61, 68) =]]
7275
```
7376

7477
#### Creating variants
7578

76-
To create a product variant, use `LocalProductService::createProductVariants()`.
77-
This method takes the product and an array of `ProductVariantCreateStruct` objects as parameters.
79+
To create a product variant, use `LocalProductServiceInterface::createProductVariants()`.
80+
This method takes the product and an array of [`ProductVariantCreateStruct`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-Product-ProductVariantCreateStruct.html) objects as parameters.
7881
`ProductVariantCreateStruct` specifies the attribute values and the code for the new variant.
7982

8083
``` php
@@ -83,7 +86,7 @@ This method takes the product and an array of `ProductVariantCreateStruct` objec
8386

8487
### Product assets
8588

86-
You can get assets assigned to a product by using `AssetServiceInterface`.
89+
You can get assets assigned to a product by using [`AssetServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AssetServiceInterface.html).
8790

8891
Use `AssetServiceInterface` to get a single asset by providing the product object and the assets's ID as parameters:
8992

@@ -92,23 +95,23 @@ Use `AssetServiceInterface` to get a single asset by providing the product objec
9295
```
9396

9497
To get all assets assigned to a product, use `AssetServiceInterface::findAssets()`.
95-
You can retrieve the tags (corresponding to attribute values) of assets with the `getTags()` method:
98+
You can retrieve the tags (corresponding to attribute values) of assets with the `AssetInterface::getTags()` method:
9699

97100
``` php
98101
[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 57, 66) =]]
99102
```
100103

101104
## Product types
102105

103-
To work with product types, use `ProductTypeServiceInterface`.
106+
To work with product types, use [`ProductTypeServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-ProductTypeServiceInterface.html).
104107

105-
Get a product type object by using `ProductTypeServiceInterface::getProductType`:
108+
Get a product type object by using `ProductTypeServiceInterface::getProductType()`:
106109

107110
``` php
108111
[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 43, 44) =]]
109112
```
110113

111-
You can also get a list of product types with `ProductTypeServiceInterface::findProductTypes`:
114+
You can also get a list of product types with `ProductTypeServiceInterface::findProductTypes()`:
112115

113116
``` php
114117
[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 47, 52) =]]
@@ -117,18 +120,18 @@ You can also get a list of product types with `ProductTypeServiceInterface::find
117120
## Product availability
118121

119122
Product availability is an object which defines whether a product is available, and if so, in what stock.
120-
To manage it, use `ProductAvailabilityServiceInterface`.
123+
To manage it, use [`ProductAvailabilityServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-ProductAvailabilityServiceInterface.html).
121124

122-
To check whether a product is available (with or without stock defined), use `ProductAvailabilityServiceInterface::hasAvailability`.
125+
To check whether a product is available (with or without stock defined), use `ProductAvailabilityServiceInterface::hasAvailability()`.
123126

124-
Get the availability object with `getAvailability()`.
125-
You can then use `ProductAvailabilityServiceInterface::getStock` to get the stock number for the product:
127+
Get the availability object with `ProductAvailabilityServiceInterface::getAvailability()`.
128+
You can then use `ProductAvailabilityServiceInterface::getStock()` to get the stock number for the product:
126129

127130
```php
128131
[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 104, 109) =]] }
129132
```
130133

131-
To change availability for a product, use `updateProductAvailability()` with a `ProductAvailabilityUpdateStruct`
134+
To change availability for a product, use `ProductAvailabilityServiceInterface::updateProductAvailability()` with a [`ProductAvailabilityUpdateStruct`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Availability-ProductAvailabilityUpdateStruct.html)
132135
and provide it with the product object. The second parameter defines whether product is available,
133136
and the third whether its stock is infinite. The fourth parameter is the stock number:
134137

@@ -138,33 +141,33 @@ and the third whether its stock is infinite. The fourth parameter is the stock n
138141

139142
## Attributes
140143

141-
To get information about product attribute groups, use the `AttributeGroupServiceInterface`,
142-
or `LocalAttributeGroupServiceInterface` to modify attribute groups.
144+
To get information about product attribute groups, use the [`AttributeGroupServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AttributeGroupServiceInterface.html),
145+
or [`LocalAttributeGroupServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalAttributeGroupServiceInterface.html) to modify attribute groups.
143146

144147
`AttributeGroupServiceInterface::getAttributeGroup()` enables you to get a single attribute group by its identifier.
145-
`AttributeGroupServiceInterface::findAttributeGroups()` get all attribute groups, base on optional query:
148+
`AttributeGroupServiceInterface::findAttributeGroups()` gets attribute groups, all of them or filtered with an optional [`AttributeGroupQuery`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-AttributeGroup-AttributeGroupQuery.html) object:
146149

147150
``` php
148151
[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 71, 72) =]]
149152
[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 92, 97) =]]
150153
```
151154

152-
To create an attribute group, use `LocalAttributeGroupServiceinterface::createAttributeGroup`
153-
and provide it with an `AttributeGroupCreateStruct`:
155+
To create an attribute group, use `LocalAttributeGroupServiceinterface::createAttributeGroup()`
156+
and provide it with an [`AttributeGroupCreateStruct`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeGroup-AttributeGroupCreateStruct.html):
154157

155158
``` php
156159
[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 66, 70) =]]
157160
```
158161

159-
To get information about product attributes, use the `AttributeDefinitionServiceInterface`,
160-
or `LocalAttributeDefinitionServiceInterface` to modify attributes.
162+
To get information about product attributes, use the [`AttributeDefinitionServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AttributeDefinitionServiceInterface.html),
163+
or [`LocalAttributeDefinitionServiceInterface`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalAttributeDefinitionServiceInterface.html) to modify attributes.
161164

162165
``` php
163166
[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 78, 80) =]]
164167
```
165168

166-
To create an attribute, use `LocalAttributeGroupServiceinterface::createAttributeDefinition`
167-
and provide it with an `AttributeDefinitionCreateStruct`:
169+
To create an attribute, use `LocalAttributeGroupServiceinterface::createAttributeDefinition()`
170+
and provide it with an [`AttributeDefinitionCreateStruct`](../api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeDefinition-AttributeDefinitionCreateStruct.html):
168171

169172
``` php
170173
[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 83, 89) =]]

0 commit comments

Comments
 (0)