You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pim/product_api.md
+33-30Lines changed: 33 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,31 @@ description: Use PHP API to manage products in PIM, their attributes, availabili
8
8
9
9
[[= product_name =]]'s Product API provides two services for handling product information, which differ in function:
10
10
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
13
13
14
14
!!! tip "Product REST API"
15
15
16
16
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).
17
17
18
18
### Getting product information
19
19
20
-
Get an individual product by using the `productService::getProduct()` method:
20
+
Get an individual product by using the `ProductServiceInterface::getProduct()` method:
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
+
33
36
### Modifying products
34
37
35
38
To create, update and delete products, use the `LocalProductServiceInterface`.
@@ -38,15 +41,15 @@ To create, update and delete products, use the `LocalProductServiceInterface`.
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).
42
45
Provide the method with the product type object and the main language code.
43
46
You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`:
@@ -55,7 +58,7 @@ To delete a product, use `LocalProductService::deleteProduct()`:
55
58
### Product variants
56
59
57
60
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.
59
62
60
63
A `ProductVariantQuery` lets you define the offset and limit of the variant query.
61
64
The default offset is 0, and limit is 25.
@@ -64,17 +67,17 @@ The default offset is 0, and limit is 25.
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()`.
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.
78
81
`ProductVariantCreateStruct` specifies the attribute values and the code for the new variant.
79
82
80
83
```php
@@ -83,7 +86,7 @@ This method takes the product and an array of `ProductVariantCreateStruct` objec
83
86
84
87
### Product assets
85
88
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).
87
90
88
91
Use `AssetServiceInterface` to get a single asset by providing the product object and the assets's ID as parameters:
89
92
@@ -92,23 +95,23 @@ Use `AssetServiceInterface` to get a single asset by providing the product objec
92
95
```
93
96
94
97
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:
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).
104
107
105
-
Get a product type object by using `ProductTypeServiceInterface::getProductType`:
108
+
Get a product type object by using `ProductTypeServiceInterface::getProductType()`:
@@ -117,18 +120,18 @@ You can also get a list of product types with `ProductTypeServiceInterface::find
117
120
## Product availability
118
121
119
122
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).
121
124
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()`.
123
126
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:
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)
132
135
and provide it with the product object. The second parameter defines whether product is available,
133
136
and the third whether its stock is infinite. The fourth parameter is the stock number:
134
137
@@ -138,33 +141,33 @@ and the third whether its stock is infinite. The fourth parameter is the stock n
138
141
139
142
## Attributes
140
143
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.
143
146
144
147
`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:
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):
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.
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):
0 commit comments