PHP API Client documentation
#Resources
#Products
#Product
#Get a product
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'identifier' => 'top',
* 'enabled' => true,
* 'family' => 'tshirt',
* 'categories' => ['summer_collection'],
* 'groups' => [],
* 'parent' => null,
* 'values' => [
* 'name' => [
* [
* 'data' => 'Top',
* 'locale' => 'en_US',
* 'scope' => null,
* 'attribute_type' => 'pim_catalog_text'
* ],
* [
* 'data' => 'Débardeur',
* 'locale' => 'fr_FR',
* 'scope' => null,
* 'attribute_type' => 'pim_catalog_text'
* ],
* ],
* ],
* 'created' => '2016-06-23T18:24:44+02:00',
* 'updated' => '2016-06-25T17:56:12+02:00',
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['identifier' => 'earings', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* ]
*/
$product = $client->getProductApi()->get('top');
You can get more information about the returned format of the product values here.
In the Akeneo PIM Enterprise Edition, the response contains one more field metadata
. Look at the product drafts for an example.
The field product_models
in the associations
property was added in the 2.1 version of the PIM and is therefore not present in previous versions.
The field quantified_associations
is only available since the 5.0.
#Get a list of products
Available in all client versions
There are two ways of getting products. Also, you have a search builder to ease the construction of a research.
Search builder
You can search over the products, thanks to a list of filters. An helper has been added to ease the construction of these filters.
For more information about the available filters and operators that you can use to research a list of products, please refer to this page.
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('enabled', '=', true)
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce'])
->addFilter('categories', 'IN', 'winter_collection')
->addFilter('family', 'IN', ['camcorders', 'digital_cameras']);
$searchFilters = $searchBuilder->getFilters();
By getting pages
This method allows to get products page per page, as a classical pagination. You can research products thanks to the search builder.
As for the other entities, it's possible to get the total number of researched products with this method. Also, it's possible to filter the value to return, thanks to the query parameters that are fully described here.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// set the limit of 50 products per page, calculate the total number of researched products, apply a research
$firstPage = $client->getProductApi()->listPerPage(50, true, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter limit
.
Setting the parameter with_count
to true
can drastically decrease the performance.
It's recommended to let this parameter with the default value false
if the total number of products is not needed in the response.
You can get more information about this method here.
You can get more information about the available query parameters here.
With a cursor
This method allows to iterate the products. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or getting the total number of products.
As for the paginated method, the search builder can be used and all query parameters are available, except with_count
.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// get a cursor with a page size of 50, apply a research
$products = $client->getProductApi()->all(50, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter pageSize
.
You can get more information about this method here.
You can get more information about the available query parameters here.
#Create a product
Available in all client versions
If the product does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductApi()->create('top', [
'enabled' => true,
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'parent'=> null,
'values' => [
'name' => [
[
'data' => 'top',
'locale' => 'en_US',
'scope' => null,
],
[
'data' => 'Débardeur',
'locale' => 'fr_FR',
'scope' => null,
],
],
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
]
);
You can get more information about the expected format of the product values here.
#Upsert a product
Available in all client versions
If the product does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductApi()->upsert('top', [
'enabled' => true,
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'parent'=> null,
'values' => [
'name' => [
[
'data' => 'top',
'locale' => 'en_US',
'scope' => null,
],
[
'data' => 'Débardeur',
'locale' => 'fr_FR',
'scope' => null,
],
],
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
]
);
You can get more information about the expected format of the product values here.
If you are using a v2.0 Enterprise Edition PIM, permissions based on your user groups are applied to the product you try to upsert. If you have edit rights but do not own the product, then it will create a product draft instead of updating the product.
#Upsert a list of products
Available in all client versions
This method allows to create or update a list of products.
It has the same behavior as the upsert
method for a single product, except that the code must be specified in the data of each product.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$responseLines = $client->getProductApi()->upsertList([
[
'identifier' => 'top',
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'values' => [
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
],
],
[
'identifier' => 'cap',
'categories' => ['hat'],
],
]);
foreach ($responseLines as $line) {
echo $line['line'];
echo $line['identifier'];
echo $line['status_code'];
if (isset($line['message'])) {
echo $line['message'];
}
}
There is a limit on the maximum number of products that you can upsert in one time on server side. By default this limit is set to 100.
You can get a complete description of the expected format and the returned format here.
#Delete a product
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductApi()->delete('top');
#Product UUID
The following endpoints are largely the same as for products. The difference? Here, you can query, create or update products identified by their uuid. More information here.
#Get a product
Available since client version: 10.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f3',
* 'enabled' => true,
* 'family' => 'tshirt',
* 'categories' => ['summer_collection'],
* 'groups' => [],
* 'parent' => null,
* 'values' => [
* 'sku' => [
* [
* 'locale' => null,
* 'scope' => null,
* 'data' => 'top',
* 'attribute_type' => 'pim_catalog_identifier'
* ]
* ],
* 'name' => [
* [
* 'data' => 'Top',
* 'locale' => 'en_US',
* 'scope' => null,
* 'attribute_type' => 'pim_catalog_text'
* ],
* [
* 'data' => 'Débardeur',
* 'locale' => 'fr_FR',
* 'scope' => null,
* 'attribute_type' => 'pim_catalog_text'
* ],
* ],
* ],
* 'created' => '2022-08-23T18:24:44+02:00',
* 'updated' => '2022-08-25T17:56:12+02:00',
* 'associations' => [
* 'PACK' => [
* 'products' => [
* '12951d98-210e-4bRC-ab18-7fdgf1bd14f5'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f4', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* ]
*/
$product = $client->getProductUuidApi()->get('12951d98-210e-4bRC-ab18-7fdgf1bd14f3');
#Get a list of products
Available since client version: 10.0
There are two ways of getting products. Also, you have a search builder to ease the construction of a research.
Search builder
You can search over the products, thanks to a list of filters. An helper has been added to ease the construction of these filters.
For more information about the available filters and operators that you can use to research a list of products, please refer to this page.
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('enabled', '=', true)
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce'])
->addFilter('categories', 'IN', 'winter_collection')
->addFilter('family', 'IN', ['camcorders', 'digital_cameras']);
$searchFilters = $searchBuilder->getFilters();
By getting pages
This method allows to get products page per page, as a classical pagination. You can research products thanks to the search builder.
As for the other entities, it's possible to get the total number of researched products with this method. Also, it's possible to filter the value to return, thanks to the query parameters that are fully described here.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// set the limit of 50 products per page, calculate the total number of researched products, apply a research
$firstPage = $client->getProductUuidApi()->listPerPage(50, true, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter limit
.
Setting the parameter with_count
to true
can drastically decrease the performance.
It's recommended to let this parameter with the default value false
if the total number of products is not needed in the response.
You can get more information about this method here.
You can get more information about the available query parameters here.
With a cursor
This method allows to iterate the products. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or getting the total number of products.
As for the paginated method, the search builder can be used and all query parameters are available, except with_count
.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// get a cursor with a page size of 50, apply a research
$products = $client->getProductUuidApi()->all(50, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter pageSize
.
You can get more information about this method here.
You can get more information about the available query parameters here.
#Create a product
Available since client version: 10.0
If the product does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductUuidApi()->create('844c736b-a19b-48a6-a354-6056044729f0', [
'uuid' => '844c736b-a19b-48a6-a354-6056044729f0',
'enabled' => true,
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'parent'=> null,
'values' => [
'sku' => [
[
'locale' => null,
'scope' => null,
'data' => 'top'
]
],
'name' => [
[
'data' => 'top',
'locale' => 'en_US',
'scope' => null,
],
[
'data' => 'Débardeur',
'locale' => 'fr_FR',
'scope' => null,
],
],
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
]
);
You can get more information about the expected format of the product values here.
#Upsert a product
Available since client version: 10.0
If the product does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductUuidApi()->upsert('844c736b-a19b-48a6-a354-6056044729f0', [
'uuid' => '844c736b-a19b-48a6-a354-6056044729f0',
'enabled' => true,
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'parent'=> null,
'values' => [
'sku' => [
[
'locale' => null,
'scope' => null,
'data' => 'top'
]
],
'name' => [
[
'data' => 'top',
'locale' => 'en_US',
'scope' => null,
],
[
'data' => 'Débardeur',
'locale' => 'fr_FR',
'scope' => null,
],
],
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
]
);
You can get more information about the expected format of the product values here.
#Upsert a list of products
Available since client version: 10.0
This method allows to create or update a list of products.
It has the same behavior as the upsert
method for a single product, except that the code must be specified in the data of each product.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$responseLines = $client->getProductUuidApi()->upsertList([
[
'uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f3',
'family' => 'tshirt',
'categories' => ['summer_collection'],
'groups' => [],
'values' => [
'sku' => [
[
'locale' => null,
'scope' => null,
'data' => 'top'
]
],
'price' => [
[
'data' => [
[
'amount' => '15.5',
'currency' => 'EUR',
],
[
'amount' => '15',
'currency' => 'USD',
],
],
'locale' => null,
'scope' => null,
],
],
],
],
[
'uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f4',
'categories' => ['hat'],
],
]);
foreach ($responseLines as $line) {
echo $line['line'];
echo $line['uuid'];
echo $line['status_code'];
if (isset($line['message'])) {
echo $line['message'];
}
}
There is a limit on the maximum number of products that you can upsert in one time on server side. By default this limit is set to 100.
You can get a complete description of the expected format and the returned format here.
#Delete a product
Available since client version: 10.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductUuidApi()->delete('12951d98-210e-4bRC-ab18-7fdgf1bd14f4');
#Product model
#Get a product model
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'rain_boots_red',
* 'family_variant' => 'boots_color_size',
* 'parent' => 'rain_boots',
* 'categories' => ['2014_collection', 'winter_collection', 'winter_boots'],
* 'values' => [
* 'name' => [
* [
* 'locale' => 'en_US',
* 'scope' => null,
* 'data' => 'Red rain boots',
* ]
* ],
* ],
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['identifier' => 'earings', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* 'created' => '2017-10-17T14:12:35+00:00',
* 'updated' => '2017-10-17T14:12:35+00:00'
* ]
*/
$productModel = $client->getProductModelApi()->get('rain_boots_red');
You can get more information about the returned format of the product values here.
Since the 2.3 version, in the Akeneo PIM Enterprise Edition, the response contains one more field metadata
. Look at the product model drafts for an example.
#Get a list of product models
Available in all client versions
There are two ways of getting product models.
Search builder
This feature is only available since the version 3.0 of the PHP API client. Also it was added in the 2.3 version of the PIM and is therefore not present in previous versions.
You can search over the product models, thanks to a list of filters. A helper has been added to ease the construction of these filters.
For more information about the available filters and operators that you can use to search a list of product models, please refer to this page.
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', 'AT LEAST COMPLETE', ['locale' => 'en_US'])
->addFilter('completeness', 'ALL COMPLETE', ['scope' => 'ecommerce'])
->addFilter('categories', 'IN', 'winter_collection');
$searchFilters = $searchBuilder->getFilters();
By getting pages
This method allows you to get product models page per page, as a classical pagination.
It's possible to get the total number of product models with this method.
As for the paginated method, since the 3.0 version of the PHP client, the search builder can be used and all query parameters are available, except with_count
.
For example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', 'ALL COMPLETE', ['locale' => 'en_US', 'scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// get a cursor with a page size of 50, apply a search
$products = $client->getProductModelApi()->all(50, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter limit
.
Setting the parameter with_count
to true
can drastically decrease the performance.
It's recommended to let this parameter with the default value false
if the total number of product models is not needed in the response.
You can get more information about this method here.
With a cursor
This method allows you to iterate the product models. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or get the total number of product models.
As for the paginated method, since the 3.0 version of the PHP client, the search builder can be used and all query parameters are available, except with_count
.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', 'ALL COMPLETE', ['locale' => 'en_US']);
$searchFilters = $searchBuilder->getFilters();
// get a cursor with a page size of 50, apply a research
$productModels = $client->getProductModelApi()->all(50, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter pageSize
.
You can get more information about this method here.
You can get more information about the available query parameters here.
#Create a product model
Available in all client versions
If the product model does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductModelApi()->create('saddle_rain_boots', [
'family_variant' => 'boots_color_size',
'parent' => 'rain_boots',
'categories' => ['2014_collection', 'winter_boots', 'winter_collection'],
'values' => [
'name' => [
[
'locale' => 'en_US',
'scope' => null,
'data' => 'Saddle rain boots',
]
],
'color' => [
[
'locale' => null,
'scope' => null,
'data' => 'saddle'
]
]
]
]);
Product model values use the same format as the product values. If you want to know more, take a look at here.
#Upsert a product model
Available in all client versions
If the product model does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductModelApi()->upsert('rain_boots_red', [
'categories' => ['2014_collection', 'winter_boots']
]);
#Upsert a list of product models
Available in all client versions
This method allows to create or update a list of product models.
It has the same behavior as the upsert
method for a single product model, except that the code must be specified in the data of each product models.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$responseLines = $client->getProductModelApi()->upsertList([
[
'code' => 'rain_boots_red',
'family_variant' => 'rain_boots_color_size',
'parent' => 'rain_boots',
'categories' => ['2014_collection', 'winter_boots']
],
[
'code' => 'rain_boots_saddle',
'family_variant' => 'rain_boots_color_size',
'parent' => 'rain_boots',
'categories' => ['2014_collection', 'winter_boots'],
'values' => [
'description' => [
[
'locale' => 'en_US',
'scope' => 'ecommerce',
'data' => 'Saddle rain boots made of rubber for winter.'
]
]
]
]
]);
foreach ($responseLines as $line) {
echo $line['line'];
echo $line['identifier'];
echo $line['status_code'];
if (isset($line['message'])) {
echo $line['message'];
}
}
There is a limit on the maximum number of product models that you can upsert in one time on server side. By default this limit is set to 100.
#Product draft UUID
The following endpoints are largely the same as for products. The difference? Here, you can query or drafts identified by their uuid. More information here.
#Get a product draft
Available since client version: 10.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f3',
* 'enabled' => true,
* 'family' => 'tshirt',
* 'categories' => ['summer_collection'],
* 'groups' => [],
* 'values' => [
* 'sku' => [
* [
* 'locale' => null,
* 'scope' => null,
* 'data' => 'top'
* ]
* ],
* 'name' => [
* [
* 'data' => 'Top',
* 'locale' => 'en_US',
* 'scope' => null
* ],
* [
* 'data' => 'Débardeur',
* 'locale' => 'fr_FR',
* 'scope' => null
* ],
* ],
* ],
* 'created' => '2016-06-23T18:24:44+02:00',
* 'updated' => '2016-06-25T17:56:12+02:00',
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['uuid' => '5719e119-613c-49af-9244-fa39a9e0cb1d', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* 'metadata' => [
* 'workflow_status' => 'draft_in_progress',
* ],
* ]
*/
$draftProduct = $client->getProductDraftUuidApi()->get('12951d98-210e-4bRC-ab18-7fdgf1bd14f3');
You can get more information about the returned format of the product values here.
The field metadata
is specific to Akeneo PIM Enterprise Edition. The status of the draft is specified in this field.
#Submit a product draft for approval
Available since client version: 10.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductDraftUuidApi()->submitForApproval('12951d98-210e-4bRC-ab18-7fdgf1bd14f3');
It is mandatory that the user already created a draft for this product, and that this draft was not approved yet.
#Async Calls
Available since client version: 11.3
$upsertListResponseFactory = new UpsertResourceListResponseFactory();
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'username', 'password');
$promise = $client->getProductApi()->upsertAsyncList($productToUpsert);
$response = $upsertListResponseFactory->create($promise->wait()->getBody());
All the requests are synchronous by default. But since the version 11.3 of the PHP client, you can now use asynchronous requests on all resources available through the API. For example, to upsert asynchronously a list of resources, you need to use the upsertAsyncList
method instead of the upsertList
one. This method returns a promise that you can wait for to get the response.
#Product draft
#Get a product draft
Available in all client versions | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'identifier' => 'top',
* 'enabled' => true,
* 'family' => 'tshirt',
* 'categories' => ['summer_collection'],
* 'groups' => [],
* 'values' => [
* 'name' => [
* [
* 'data' => 'Top',
* 'locale' => 'en_US',
* 'scope' => null
* ],
* [
* 'data' => 'Débardeur',
* 'locale' => 'fr_FR',
* 'scope' => null
* ],
* ],
* ],
* 'created' => '2016-06-23T18:24:44+02:00',
* 'updated' => '2016-06-25T17:56:12+02:00',
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['identifier' => 'earings', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* 'metadata' => [
* 'workflow_status' => 'draft_in_progress',
* ],
* ]
*/
$draftProduct = $client->getProductDraftApi()->get('top');
You can get more information about the returned format of the product values here.
The field metadata
is specific to Akeneo PIM Enterprise Edition. The status of the draft is specified in this field.
The field product_models
in the associations
property was added in the 2.1 version of the PIM and is therefore not present in previous versions.
The field quantified_associations
is only available since the 5.0.
#Submit a product draft for approval
Available in all client versions | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductDraftApi()->submitForApproval('top');
It is mandatory that the user already created a draft for the product top
, and that this draft was not approved yet.
#Product media file
#Get media file information
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'code/example',
* 'original_filename' => 'ziggy.jpg',
* 'mime_type' => 'image/jpeg',
* 'size' => 1337,
* 'extension' => 'jpg',
* '_links' => [
* 'download' => [
* 'href' => 'http://localhost/api/rest/v1/media-files/code/example/download',
* ],
* ],
* ];
*/
$media = $client->getProductMediaFileApi()->get('code/example');
#Download media file
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFile = $client->getProductMediaFileApi()->download('code/example');
file_put_contents('/tmp/ziggy.jpg', $mediaFile->getContents());
From the v4 of the PHP client, the response is returned instead of the content. It allows getting the filename and the MIME type from the response. You can get the content this way:
file_put_contents('/tmp/bridge.jpg', $mediaFile->getBody()->getContents());
#Get a list of media file information
Available in all client versions
There are two ways of getting media files.
By getting pages
This method allows to get media files page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getProductMediaFileApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the media files. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or getting the total number of media files.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
// get a cursor with a page size of 50, apply a research
$mediaFiles = $client->getProductMediaFileApi()->all(50);
You can get more information about this method here.
#Create a new media file
Available in all client versions
When you create a media file, you can directly associate it to either a product or a product model.
Association to a product
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductMediaFileApi()->create('/tmp/ziggy.jpg', [
'identifier' => 'medium_boot',
'attribute' => 'side_view',
'scope' => 'ecommerce',
'locale' => 'en_US',
]);
Association to a product model
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductMediaFileApi()->create('/tmp/ziggy.jpg', [
'code' => 'rain_boots',
'attribute' => 'product_model_media',
'scope' => null,
'locale' => 'en_US',
'type' => 'product_model',
]);
#Product model draft
#Get a product model draft
Available since client version: 3.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'rain_boots_red',
* 'family_variant' => 'boots_color_size',
* 'parent' => 'rain_boots',
* 'categories' => ['2014_collection', 'winter_collection', 'winter_boots'],
* 'values' => [
* 'name' => [
* [
* 'locale' => 'en_US',
* 'scope' => null,
* 'data' => 'Red rain boots',
* ]
* ],
* ],
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* 'quantified_associations' => [
* 'PRODUCT_SET' => [
* 'products' => [
* ['identifier' => 'earings', 'quantity' => 2],
* ],
* 'product_models' => [],
* ],
* ],
* 'created' => '2017-10-17T14:12:35+00:00',
* 'updated' => '2017-10-17T14:12:35+00:00',
* 'metadata' => [
* 'workflow_status' => 'draft_in_progress',
* ],
* ]
*/
$draftProduct = $client->getProductModelDraftApi()->get('rain_boots_red');
You can get more information about the returned format of the product values here.
The field metadata
is specific to Akeneo PIM Enterprise Edition. The status of the draft is specified in this field.
#Submit a product model draft for approval
Available since client version: 3.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getProductModelDraftApi()->submitForApproval('rain_boots_red');
It is mandatory that the user already created a draft for the product model rain_boots_red
, and that this draft was not approved yet.
#Published product - Deprecated
#Get a published product
Available in all client versions | Only available for PIM EE
Important update: Published Products discontinuation. This feature is no longer actively supported and will soon be retired. We recommend exploring alternative solutions. Learn more in the help center
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'identifier' => 'top',
* 'enabled' => true,
* 'family' => 'tshirt',
* 'categories' => ['summer_collection'],
* 'groups' => [],
* 'values' => [
* 'name' => [
* [
* 'data' => 'Top',
* 'locale' => 'en_US',
* 'scope' => null
* ],
* [
* 'data' => 'Débardeur',
* 'locale' => 'fr_FR',
* 'scope' => null
* ],
* ],
* ],
* 'created' => '2016-06-23T18:24:44+02:00',
* 'updated' => '2016-06-25T17:56:12+02:00',
* 'associations' => [
* 'PACK' => [
* 'products' => [
* 'sunglass'
* ],
* 'groups' => [],
* 'product_models' => []
* ],
* ],
* ]
*/
$publishedProduct = $client->getPublishedProductApi()->get('top');
You can get more information about the returned format of the product values here.
The field product_models
in the associations
property was added in the 2.1 version of the PIM and is therefore not present in previous versions.
The field quantified_associations
is only available since the 5.0.
#Get a list of published products
Available in all client versions | Only available for PIM EE
There are two ways of getting published products. Like for the products, you can use the search builder to ease the construction of a research.
By getting pages
This method allows to get published products page per page, as a classical pagination. You can research published products thanks to the search builder.
As for the other entities, it's possible to get the total number of researched published products with this method. Also, it's possible to filter the value to return, thanks to the query parameters that are fully described here.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '<', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// set the limit of 50 published products per page, calculate the total number of researched published products, apply a research
$firstPage = $client->getPublishedProductApi()->listPerPage(50, true, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter limit
.
Setting the parameter with_count
to true
can drastically decrease the performance.
It's recommended to let this parameter with the default value false
if the total number of published products is not needed in the response.
You can get more information about this method here.
You can get more information about the available query parameters here.
With a cursor
This method allows to iterate the published products. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or getting the total number of published products.
As for the paginated method, the search builder can be used and all query parameters are available, except with_count
.
For example, in this example, we only return product values belonging to the channel "ecommerce" by adding the query parameter 'scope' => 'ecommerce'
.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
$searchBuilder
->addFilter('completeness', '>', 70, ['scope' => 'ecommerce'])
->addFilter('completeness', '8', 85, ['scope' => 'ecommerce']);
$searchFilters = $searchBuilder->getFilters();
// get a cursor with a page size of 50, apply a research
$publishedProducts = $client->getPublishedProductApi()->all(50, ['search' => $searchFilters, 'scope' => 'ecommerce']);
There is a maximum limit allowed on server side for the parameter pageSize
.
You can get more information about this method here.
You can get more information about the available query parameters here.
#Catalog structure
#Association type
#Get an association type
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'X_SELL',
* 'labels' => [
* 'en_US' => 'Cross sell',
* 'fr_FR' => 'Vente croisée',
* ],
* 'is_quantified' => false,
* 'is_two_way' => false,
* ]
*/
$associationType = $client->getAssociationTypeApi()->get('X_SELL');
#Get a list of association types
Available in all client versions
There are two ways of getting association types.
By getting pages
This method allows to get association types page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAssociationTypeApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the association types. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$associationTypes = $client->getAssociationTypeApi()->all(50);
You can get more information about this method here.
#Create an association type
Available in all client versions
If the association type does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssociationTypeApi()->create('NEW_SELL', [
'labels' => [
'en_US' => 'New sell',
'fr_FR' => 'Nouvelle vente',
]
]);
#Upsert an association type
Available in all client versions
If the association type does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssociationTypeApi()->upsert('NEW_SELL', [
'labels' => [
'en_US' => 'New sell',
'fr_FR' => 'Nouvelle vente',
]
]);
#Upsert a list of association types
Available in all client versions
This method allows to create or update a list of association types.
It has the same behavior as the upsert
method for a single association type, except that the code must be specified in the data of each association type.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssociationTypeApi()->upsertList([
[
'code' => 'NEW_SELL',
'labels' => [
'en_US' => 'New sell',
'fr_FR' => 'Nouvelle vente',
]
],
[
'code' => 'UPSELL',
'labels' => [
'en_US' => 'Upsell',
'fr_FR' => 'Vente incitative',
]
],
]);
There is a limit on the maximum number of association types that you can upsert in one time on server side. By default this limit is set to 100.
#Attribute group
#Get an attribute group
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'marketing',
* 'attributes' => ['sku', 'name', 'description', 'response_time', 'release_date', 'price'],
* 'sort_order' => 4,
* 'labels' => [
* 'en_US' => 'Marketing',
* 'fr_FR' => 'Marketing',
* ],
* ]
*/
$attributeGroup = $client->getAttributeGroupApi()->get('marketing');
#Get a list of attribute groups
Available in all client versions
There are two ways of getting attribute groups.
By getting pages
This method allows to get attribute groups page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAttributeGroupApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the attribute groups. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$attributeGroups = $client->getAttributeGroupApi()->all(50);
You can get more information about this method here.
#Create an attribute group
Available in all client versions
If the attribute group does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeGroupApi()->create('media', [
'attribute' => ['side_view'],
'labels' => [
'en_US' => 'Media',
'fr_FR' => 'Médias',
]
]);
#Upsert an attribute group
Available in all client versions
If the attribute group does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeGroupApi()->upsert('marketing', [
'attributes' => ['sku', 'name', 'description'],
'labels' => [
'en_US' => 'Marketing',
'fr_FR' => 'Marketing',
]
]);
#Upsert a list of attribute groups
Available in all client versions
This method allows to create or update a list of attribute groups.
It has the same behavior as the upsert
method for a single attribute group, except that the code must be specified in the data of each attribute group.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeGroupApi()->upsertList([
[
'code' => 'marketing',
'attributes' => ['sku', 'name', 'description'],
'labels' => [
'en_US' => 'Marketing',
'fr_FR' => 'Marketing',
]
],
[
'code' => 'media',
'attribute' => ['side_view'],
'labels' => [
'en_US' => 'Media',
'fr_FR' => 'Médias',
]
],
]);
There is a limit on the maximum number of attribute groups that you can upsert in one time on server side. By default this limit is set to 100.
#Attribute option
#Get an attribute option
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'black',
* 'attribute' => 'a_simple_select',
* 'sort_order' => 2,
* 'labels' => [
* 'en_US' => 'Black',
* 'fr_FR' => 'Noir',
* ]
* ]
*/
$attributeOption = $client->getAttributeOptionApi()->get('a_simple_select', 'black');
#Get a list of attribute options
Available in all client versions
There are two ways of getting attribute options.
By getting pages
This method allows to get attribute options page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAttributeOptionApi()->listPerPage('a_simple_select', 50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the attribute options. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$attributes = $client->getAttributeOptionApi()->all('a_simple_select', 50);
You can get more information about this method here.
#Create an attribute
Available in all client versions
If the attribute option does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeOptionApi()->create('a_simple_select', 'black', [
'sort_order' => 2,
'labels' => [
'en_US' => 'Black',
'fr_FR' => 'Noir',
]
]);
#Upsert an attribute option
Available in all client versions
If the attribute option does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeOptionApi()->upsert('a_simple_select', 'black', [
'sort_order' => 2,
'labels' => [
'en_US' => 'Black',
'fr_FR' => 'Noir',
]
]);
#Upsert a list of attribute options
Available since client version: 2.0
This method allows to create or update a list of attribute options.
It has the same behavior as the upsert
method for a single attribute option, except that the code and the attribute must be specified in the data of each attribute option.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeOptionApi()->upsertList('a_simple_select',
[
[
'code' => 'black',
'sort_order' => 2,
'labels' => [
'en_US' => 'Black',
'fr_FR' => 'Noir',
]
],
[
'code' => 'white',
'sort_order' => 3,
'labels' => [
'en_US' => 'White',
'fr_FR' => 'Blanc',
],
],
]);
There is a limit on the maximum number of attribute options that you can upsert in one time on server side. By default this limit is set to 100.
#Attribute
#Get an attribute
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'release_date',
* 'type' => 'pim_catalog_date',
* 'group' => 'marketing',
* 'unique' => false,
* 'useable_as_grid_filter' => true,
* 'allowed_extensions' => [],
* 'metric_family' => null,
* 'default_metric_unit' => null,
* 'reference_data_name' => null,
* 'available_locales' => [],
* 'max_characters' => null,
* 'validation_rule' => null,
* 'validation_regexp' => null,
* 'wysiwyg_enabled' => null,
* 'number_min' => null,
* 'number_max' => null,
* 'decimals_allowed' => null,
* 'negative_allowed' => null,
* 'date_min' => '2017-06-28T08:00:00',
* 'date_max' => '2017-08-08T22:00:00',
* 'max_file_size' => null,
* 'minimum_input_length' => null,
* 'sort_order' => 1,
* 'localizable' => false,
* 'scopable' => false,
* 'labels' => [
* 'en_US' => 'Sale date',
* 'fr_FR' => 'Date des soldes',
* ],
* 'guidelines' => [
* 'en_US' => 'Fill the release date for the summer sale 2017',
* 'fr_FR' => 'Renseigner la date des soldes pour l\'été 2017',
* ],
* ]
*/
$attribute = $client->getAttributeApi()->get('release_date');
#Get a list of attributes
Available in all client versions
There are two ways of getting attributes.
By getting page
This method allows to get attributes page per page, as a classical pagination. It's possible to get the total number of attributes with this method.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAttributeApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the attributes. It will automatically get the next pages for you. With this method, it's not possible to get the previous page, or getting the total number of attributes.
$client = (new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/'))->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$attributes = $client->getAttributeApi()->all(50);
You can get more information about this method here.
#Create an attribute
Available in all client versions
If the attribute does not exist yet, this method creates it, otherwise it throws an exception.
$client = (new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/'))->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeApi()->create('release_date', [
'type' => 'pim_catalog_date',
'group' => 'marketing',
'unique' => false,
'useable_as_grid_filter' => true,
'allowed_extensions' => [],
'metric_family' => null,
'default_metric_unit' => null,
'reference_data_name' => null,
'available_locales' => [],
'max_characters' => null,
'validation_rule' => null,
'validation_regexp' => null,
'wysiwyg_enabled' => null,
'number_min' => null,
'number_max' => null,
'decimals_allowed' => null,
'negative_allowed' => null,
'date_min' => '2017-06-28T08:00:00',
'date_max' => '2017-08-08T22:00:00',
'max_file_size' => null,
'minimum_input_length' => null,
'sort_order' => 1,
'localizable' => false,
'scopable' => false,
'labels' => [
'en_US' => 'Sale date',
'fr_FR' => 'Date des soldes',
],
'guidelines' => [
'en_US' => 'Fill the release date for the summer sale 2017',
'fr_FR' => 'Renseigner la date des soldes pour l\'été 2017',
],
]);
#Upsert an attribute
Available in all client versions
If the attribute does not exist yet, this method creates it, otherwise it updates it.
$client = (new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/'))->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeApi()->upsert('release_date', [
'type' => 'pim_catalog_date',
'group' => 'marketing',
'unique' => false,
'useable_as_grid_filter' => true,
'allowed_extensions' => [],
'metric_family' => null,
'default_metric_unit' => null,
'reference_data_name' => null,
'available_locales' => [],
'max_characters' => null,
'validation_rule' => null,
'validation_regexp' => null,
'wysiwyg_enabled' => null,
'number_min' => null,
'number_max' => null,
'decimals_allowed' => null,
'negative_allowed' => null,
'date_min' => '2017-06-28T08:00:00',
'date_max' => '2017-08-08T22:00:00',
'max_file_size' => null,
'minimum_input_length' => null,
'sort_order' => 1,
'localizable' => false,
'scopable' => false,
'labels' => [
'en_US' => 'Sale date',
'fr_FR' => 'Date des soldes',
],
'guidelines' => [
'en_US' => 'Fill the release date for the summer sale 2017',
'fr_FR' => 'Renseigner la date des soldes pour l\'été 2017',
],
]);
#Upsert a list of attributes
Available in all client versions
This method allows to create or update a list of attributes.
It has the same behavior as the upsert
method for a single attribute, except that the code must be specified in the data of each attribute.
$client = (new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/'))->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAttributeApi()->upsertList([
[
'code' => 'release_date',
'type' => 'pim_catalog_date',
'group' => 'marketing',
'unique' => false,
'useable_as_grid_filter' => true,
'allowed_extensions' => [],
'metric_family' => null,
'default_metric_unit' => null,
'reference_data_name' => null,
'available_locales' => [],
'max_characters' => null,
'validation_rule' => null,
'validation_regexp' => null,
'wysiwyg_enabled' => null,
'number_min' => null,
'number_max' => null,
'decimals_allowed' => null,
'negative_allowed' => null,
'date_min' => '2017-06-28T08:00:00',
'date_max' => '2017-08-08T22:00:00',
'max_file_size' => null,
'minimum_input_length' => null,
'sort_order' => 1,
'localizable' => false,
'scopable' => false,
'labels' => [
'en_US' => 'Sale date',
'fr_FR' => 'Date des soldes',
],
'guidelines' => [
'en_US' => 'Fill the release date for the summer sale 2017',
'fr_FR' => 'Renseigner la date des soldes pour l\'été 2017',
],
],
[
'code' => 'name',
'type' => 'pim_catalog_text',
'labels' => [
'en_US' => 'Name',
'fr_FR' => 'Nom',
]
],
]);
There is a limit on the maximum number of attributes that you can upsert in one time on server side. By default this limit is set to 100.
#Category
#Get a category
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'winter_collection',
* 'parent' => 'master',
* 'labels' => [
* 'en_US' => 'Winter collection',
* 'fr_FR' => 'Collection hiver',
* ]
* ]
*/
$category = $client->getCategoryApi()->get('master');
#Get a list of categories
Available in all client versions
There are two ways of getting categories.
By getting pages
This method allows to get categories page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getCategoryApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the categories. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$categories = $client->getCategoryApi()->all(50);
You can get more information about this method here.
#Create a category
Available in all client versions
If the category does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getCategoryApi()->create('winter_collection', [
'parent' => 'master',
'labels' => [
'en_US' => 'Winter collection',
'fr_FR' => 'Collection hiver',
]
]);
#Upsert a category
Available in all client versions
If the category does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getCategoryApi()->upsert('winter_collection', [
'parent' => 'master',
'labels' => [
'en_US' => 'Winter collection',
'fr_FR' => 'Collection hiver',
]
]);
#Upsert a list of categories
Available in all client versions
This method allows to create or update a list of categories.
It has the same behavior as the upsert
method for a single category, except that the code must be specified in the data of each category.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getCategoryApi()->upsertList([
[
'code' => 'winter_collection',
'parent' => 'master',
'labels' => [
'en_US' => 'Winter collection',
'fr_FR' => 'Collection hiver',
]
],
[
'code' => 'helicopter',
'parent' => 'machine',
'labels' => [
'en_US' => 'Helicopter',
'fr_FR' => 'Hélicoptere',
]
],
]);
There is a limit on the maximum number of categories that you can upsert in one time on server side. By default this limit is set to 100.
#Category media file
#Download media file
Available since client version: 11.2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFile = $client->getCategoryMediaFileApi()->download('code/example');
file_put_contents('/tmp/ziggy.jpg', $mediaFile->getBody());
#Get categories with attribute values
Available since client version: 11.2.0
$firstPage = $client->getCategoryApi()->listPerPage(50, true, ['with_enriched_attributes' => true]);
foreach ($firstPage->getItems() as $category) {
foreach ($category['values'] as $value) {
if ($value['type'] === 'image') {
$filePath = $value['data']['file_path'];
// Download image file for attribute of type image
$mediaFile = $client->getCategoryMediaFileApi()->download($filePath);
file_put_contents(
'/tmp/' . $value['attribute_code'] . $value['data']['extension'],
$mediaFile->getBody()
);
}
}
}
#Family
#Get a family
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'caps',
* 'attributes' => ['sku', 'name', 'description', 'price', 'color'],
* 'attribute_as_label' => 'name',
* 'attribute_as_image' => 'picture',
* 'attribute_requirements' => [
* 'ecommerce' => ['sku', 'name', 'description', 'price', 'color'],
* 'tablet' => ['sku', 'name', 'description', 'price'],
* ],
* 'labels' => [
* 'en_US' => 'Caps',
* 'fr_FR' => 'Casquettes',
* ]
* ]
*/
$family = $client->getFamilyApi()->get('master');
#Get a list of families
Available in all client versions
There are two ways of getting families.
By getting pages
This method allows to get families page per page, as a classical pagination. It's possible to get the total number of families with this method.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getFamilyApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the families. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$families = $client->getFamilyApi()->all(50);
You can get more information about this method here.
#Create a family
Available in all client versions
If the family does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/', 'client_id', 'secret', 'admin', 'admin')->build()
$client->getFamilyApi()->create('caps', [
'attributes' => ['sku', 'name', 'description', 'price', 'color'],
'attribute_as_label' => 'name',
'attribute_as_image' => 'picture',
'attribute_requirements' => [
'ecommerce' => ['sku', 'name', 'description', 'price', 'color'],
'tablet' => ['sku', 'name', 'description', 'price'],
],
'labels' => [
'en_US' => 'Caps',
'fr_FR' => 'Casquettes',
]
]);
#Upsert a family
Available in all client versions
If the family does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getFamilyApi()->upsert('cap', [
'attributes' => ['sku', 'name', 'description', 'price', 'color'],
'attribute_as_label' => 'name',
'attribute_as_image' => 'picture',
'attribute_requirements' => [
'ecommerce' => ['sku', 'name', 'description', 'price', 'color'],
'tablet' => ['sku', 'name', 'description', 'price'],
],
'labels' => [
'en_US' => 'Caps',
'fr_FR' => 'Casquettes',
]
]);
#Upsert a list of families
Available in all client versions
This method allows to create or update a list of families.
It has the same behavior as the upsert
method for a single family, except that the code must be specified in the data of each family.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getFamilyApi()->upsertList([
[
'code' => 'caps',
'attributes' => ['sku', 'name', 'description', 'price', 'color'],
'attribute_as_label' => 'name',
'attribute_as_image' => 'picture',
'attribute_requirements' => [
'ecommerce' => ['sku', 'name', 'description', 'price', 'color'],
'tablet' => ['sku', 'name', 'description', 'price'],
],
'labels' => [
'en_US' => 'Caps',
'fr_FR' => 'Casquettes',
]
],
[
'code' => 'hat',
'attributes' => ['sku', 'name', 'description', 'price', 'color'],
'attribute_as_label' => 'name',
'attribute_as_image' => 'picture',
'attribute_requirements' => [
'ecommerce' => ['sku', 'name', 'color'],
'tablet' => ['sku', 'name'],
],
'labels' => [
'en_US' => 'Hat',
'fr_FR' => 'Chapeau',
]
],
]);
There is a limit on the maximum number of families that you can upsert in one time on server side. By default this limit is set to 100.
#Family variant
#Get a family variant
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'boots_color_size',
* 'labels' => [
* 'de_DE' => 'Stiefel nach Farbe und Größe',
* 'en_US' => 'Boots by color and size',
* 'fr_FR' => 'Bottes par couleur et taille'
* ],
* 'variant_attribute_sets' => [
* [
* 'level' => 1,
* 'axes' => ['color'],
* 'attributes' => ['name', 'description', 'color']
* ],
* [
* 'level' => 2,
* 'axes' => ['size'],
* 'attributes' => ['sku', 'size']
* ]
* ]
* ]
*/
$familyVariant = $client->getFamilyVariantApi()->get('boots', 'boots_color_size');
#Create a family variant
Available in all client versions
If the family variant does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getFamilyVariantApi()->create('boots', 'boots_size_color', [
'labels' => [
'en_US' => 'Boots by color and size'
],
'variant_attribute_sets' => [
[
'level' => 1,
'axes' => ['size'],
'attributes' => ['name', 'description', 'size']
],
[
'level' => 2,
'axes' => ['color'],
'attributes' => ['sku', 'color']
]
]
]);
#Get a list of family variants
Available in all client versions
There are two ways of getting family variants.
By getting pages
This method allows to get family variants page per page, as a classical pagination. It's possible to get the total number of family variants with this method.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getFamilyVariantApi()->listPerPage('boots', 50, true);
There is a maximum limit allowed on server side for the parameter limit
.
Setting the parameter with_count
to true
can drastically decrease the performance.
It's recommended to let this parameter with the default value false
if the total number of family variants is not needed in the response.
You can get more information about this method here.
With a cursor
This method allows to iterate the family variants. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$familyVariants = $client->getFamilyVariantApi()->all('boots', 50);
There is a maximum limit allowed on server side for the parameter pageSize
.
You can get more information about this method here.
#Upsert a family variant
Available in all client versions
If the family variant does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getFamilyVariantApi()->upsert('boots', [
'code' => 'rain_boots_color_size',
'labels' => [
'de_DE' => 'Stiefel nach Farbe und Größe',
'en_US' => 'Updating label',
'fr_FR' => 'Mise à jour du label'
]
]);
#Upsert a list of family variants
Available in all client versions
This method allows to create or update a list of family variants.
It has the same behavior as the upsert
method for a single family variant, except that the code must be specified in the data of each family variant.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$responseLines = $client->getFamilyVariantApi()->upsertList('boots', [
[
'code' => 'rain_boots_color_size',
'labels' => [
'de_DE' => 'Stiefel nach Farbe und Größe',
'en_US' => 'Updating label',
'fr_FR' => 'Mise à jour du label'
]
],
[
'code' => 'man_boots_color_size',
'labels' => [
'de_DE' => 'Stiefel nach Farbe und Größe',
'en_US' => 'Updating label',
'fr_FR' => 'Mise à jour du label'
]
]
]);
foreach ($responseLines as $line) {
echo $line['line'];
echo $line['identifier'];
echo $line['status_code'];
if (isset($line['message'])) {
echo $line['message'];
}
}
There is a limit on the maximum number of family variants that you can upsert in one time on server side. By default this limit is set to 100.
You can get a complete description of the expected format and the returned format here.
#Target market settings
#Channel
#Get a channel
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'ecommerce',
* 'currencies' => ['USD', 'EUR'],
* 'locales' => ['de_DE', 'en_US', 'fr_FR'],
* 'category_tree' => 'master',
* 'conversion_units' => [],
* 'labels' => [
* 'en_US' => 'Ecommerce',
* 'de_DE' => 'Ecommerce',
* 'fr_FR' => 'Ecommerce',
* ],
* ]
*/
$channel = $client->getChannelApi()->get('ecommerce');
#Get a list of channels
Available in all client versions
There are two ways of getting channels.
By getting pages
This method allows to get channels page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getChannelApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the channels. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$channels = $client->getChannelApi()->all(50);
You can get more information about this method here.
#Create a channel
Available in all client versions
If the channel does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getChannelApi()->create('paper', [
'category_tree' => 'master',
'currencies' => ['EUR', 'USD'],
'locales' => ['en_US', 'fr_FR']
'labels' => [
'en_US' => 'Paper',
'fr_FR' => 'Papier',
]
]);
#Upsert a channel
Available in all client versions
If the channel does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getChannelApi()->upsert('paper', [
'category_tree' => 'master',
'currencies' => ['EUR', 'USD'],
'locales' => ['en_US', 'fr_FR']
'labels' => [
'en_US' => 'Paper',
'fr_FR' => 'Papier',
]
]);
#Upsert a list of channels
Available in all client versions
This method allows to create or update a list of channels.
It has the same behavior as the upsert
method for a single channel, except that the code must be specified in the data of each channel.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getChannelApi()->upsertList([
[
'code' => 'paper',
'category_tree' => 'master',
'currencies' => ['EUR', 'USD'],
'locales' => ['en_US', 'fr_FR']
'labels' => [
'en_US' => 'Paper',
'fr_FR' => 'Papier',
]
],
[
'code' => 'ecommerce',
'currencies' => ['USD', 'EUR'],
'conversion_units' => [],
'labels' => [
'en_US' => 'Ecommerce',
]
],
]);
There is a limit on the maximum number of channels that you can upsert in one time on server side. By default this limit is set to 100.
#Currency
#Get a currency
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'EUR',
* 'enabled' => true,
* ]
*/
$currency = $client->getCurrencyApi()->get('EUR');
#Get a list of currencies
Available in all client versions
There are two ways of getting currencies.
By getting page
This method allows to get currencies page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getCurrencyApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the currencies. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$currencies = $client->getCurrencyApi()->all(50);
You can get more information about this method here.
#Locale
#Get a locale
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'en_US',
* 'enable' => true,
* ]
*/
$locale = $client->getLocaleApi()->get('en_US');
#Get a list of locales
Available in all client versions
There are two ways of getting locales.
By getting pages
This method allows to get locales page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getLocaleApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the locales. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$locales = $client->getLocaleApi()->all(50);
You can get more information about this method here.
#Measure family - Deprecated
Since the 5.0 and for the SaaS versions, we encourage you to use these new endpoints, as they are more powerful. They allow you to create/update measurement families and they guarantee the order of the conversion operations.
#Get a measure family
Available in all client versions
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'casebox',
* 'standard' => 'PIECE',
* 'units' => [
* [
* 'code' => 'PIECE',
* 'convert' => [
* 'mul' => '1',
* ],
* 'symbol' => 'Pc',
* ],
* [
* 'code' => 'DOZEN',
* 'convert' => [
* 'mul' => '12',
* ],
* 'symbol' => 'Dz',
* ],
* ],
* ]
*/
$measureFamily = $client->getMeasureFamilyApi()->get('casebox');
#Get a list of measure families
Available in all client versions
There are two ways of getting measure families.
By getting pages
This method allows to get measure families page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getMeasureFamilyApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the measure families. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$categories = $client->getMeasureFamilyApi()->all(50);
You can get more information about this method here.
#Measurement family
#Get a list of measurement families
Available since client version: 6.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* [
* 'code' => 'Angle',
* 'labels' => [
* 'en_US' => 'Angle',
* 'fr_FR' => 'Angle',
* ],
* 'standard_unit_code' => 'RADIAN',
* 'units' => [
* 'RADIAN' => [
* 'code' => 'RADIAN',
* 'labels' => [
* 'en_US' => 'Radian',
* 'fr_FR' => 'Radian',
* ],
* 'convert_from_standard' => [
* [
* 'operator' => 'mul',
* 'value' => '1',
* ],
* ],
* 'symbol' => 'rad',
* ],
* 'MILLIRADIAN' => [
* 'code' => 'MILLIRADIAN',
* 'labels' => [
* 'en_US' => 'Milliradian',
* 'fr_FR' => 'Milliradian',
* ],
* 'convert_from_standard' => [
* [
* 'operator' => 'mul',
* 'value' => '0.001',
* ],
* ],
* 'symbol' => 'mrad',
* ],
* ],
* ],
* ...
* ]
*/
$measurementFamilies = $client->getMeasurementFamilyApi()->all();
You can get a complete description of the returned format here.
There is no pagination on measurement families.
#Upsert a list of measurement families
Available since client version: 6.0
This method allows to create or update a list of measurement families.
For any given measurement family, the code
must be specified.
If the measurement family does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$responses = $client->getMeasurementFamilyApi()->upsertList([
// Add a german label to the existing measurement family "Angle"
[
'code' => 'Angle',
'labels' => [
'de_DE' => 'Winkel',
],
],
// Create a new measurement family
[
'code' => 'CUSTOM_MEASUREMENT_FAMILY',
'labels' => [
'en_US' => 'Custom measurement family',
],
'standard_unit_code' => 'CUSTOM_UNIT',
'units' => [
'CUSTOM_UNIT' => [
'code' => 'CUSTOM_UNIT',
'labels' => [
'en_US' => 'Custom unit',
],
'convert_from_standard' => [
[
'operator' => 'mul',
'value' => '1',
],
],
'symbol' => 'c',
],
],
],
]);
foreach ($responses as $response) {
echo $response['code']; // Measurement family code
echo $response['status_code']; // 201 => created, 204 => updated, 422 => invalid
}
You can get a complete description of the expected format and the returned format here.
There is a limit on the maximum number of measurement families you can store. By default this limit is set to 100.
#Asset Manager
#Asset
We refer here to the asset of the Asset Manager.
#Get an asset of a given asset family
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'jeans_care_instructions',
* 'values' => [
* 'label' => [
* 0 => [
* 'locale' => 'en_US',
* 'channel' => NULL,
* 'data' => 'Jeans care instructions',
* ],
* ],
* ],
* ]
*/
$client->getAssetManagerApi()->get('user_instructions', 'jeans_care_instructions');
#Get the list of the assets of a asset family
Available since client version: 5.0 | Only available for PIM EE
Assets are automatically paginated and can be filtered.
You can get more information about the available query parameters here.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$cursor = $client->getAssetManagerApi()->all('user_instructions');
#Upsert an asset of a given asset family
Available since client version: 5.0 | Only available for PIM EE
If the asset does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetManagerApi()->upsert('user_instructions', 'jeans_care_instructions', [
'code' => 'jeans_care_instructions',
'values' => [
'label' => [
['locale' => 'en_US', 'channel' => null, 'data' => 'Jeans care instructions'],
]
]
]);
#Upsert a list of assets of a given asset family
Available since client version: 5.0 | Only available for PIM EE
This method allows to create or update a list of assets of a given asset family.
It has the same behavior as the upsert
method for a single asset.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetManagerApi()->upsertList('user_instructions', [
[
'code' => 'jeans_care_instructions',
'values' => [
'label' => [
['locale' => 'en_US', 'channel' => null, 'data' => 'Jeans care instructions'],
]
]
],
[
'code' => 'shirts_care_instructions',
'values' => [
'label' => [
['locale' => 'en_US', 'channel' => null, 'data' => 'Shirts care instructions'],
]
]
]
]);
#Asset attribute option
We refer here to the asset attribute option of the Asset Manager.
#Get an attribute option for a given attribute of a given asset
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'blue',
* 'labels' => [
* 'en_US' => 'Blue',
* 'fr_FR' => 'Bleu',
* ]
* ]
*/
$client->getAssetAttributeOptionApi()->get('packshot', 'main_colors', 'blue);
#Get the list of attribute options of a given attribute for a given asset
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetAttributeOptionApi()->all('packshot', 'main_colors');
#Upsert an attribute option for a given attribute of a given asset
Available since client version: 5.0 | Only available for PIM EE
If the attribute option does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetAttributeOptionApi()->upsert('packshot', 'main_colors', 'blue', [
'code' => 'blue',
'labels' => [
'en_US' => 'Blue',
'fr_FR' => 'Bleu',
]
]);
#Asset attribute
We refer here to the asset attribute option of the Asset Manager.
#Get an attribute of a given asset family
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'label',
* 'labels' => [],
* 'type' => 'text',
* 'value_per_locale' => true,
* 'value_per_channel' => false,
* 'is_required_for_completeness' => false,
* 'max_characters' => NULL,
* 'is_textarea' => false,
* 'is_rich_text_editor' => false,
* 'validation_rule' => 'none',
* 'validation_regexp' => NULL,
* ]
*/
$client->getAssetAttributeApi()->get('user_instructions', 'label');
#Get the list of attributes of a given asset
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetAttributeApi()->all('user_instructions');
#Upsert an attribute of a given asset family
Available since client version: 5.0 | Only available for PIM EE
If the attribute does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetAttributeApi()->upsert('user_instructions', 'label', [
'code' => 'label',
'labels' => [
'en_US' => 'Label',
],
'type' => 'text'
]);
#Asset family
We refer here to the asset family of the Asset Manager.
#Get an asset family
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'user_instructions',
* 'labels' => [
* 'en_US' => 'User instructions',
* 'fr_FR' => 'Notice d\'utilisation',
* ],
* 'product_link_rules' => [],
* ]
*/
$client->getAssetFamilyApi()->get('user_instructions');
#Get the list of the asset families
Available since client version: 5.0 | Only available for PIM EE
You can get more information about the available query parameters here.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetFamilyApi()->all();
#Upsert an asset family
Available since client version: 5.0 | Only available for PIM EE
If the asset family does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetFamilyApi()->upsert('user_instructions', [
'code' => 'user_instructions',
'labels' => [
'en_US' => 'User instructions',
'fr_FR' => 'Notice d\'utilisation',
]
]);
#Asset media file
We refer here to the asset media file of the Asset Manager.
#Download the media file associated to a asset or a record
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFileCode = 'f/c/3/6/fc36131bf5a352261999ea8424f540fce164d66b_allie_jean_model_picture.png';
$mediaFileResponse = $client->getAssetMediaFileApi()->download($mediaFileCode);
From the response, you can retrieve the file name in the header "Content-Disposition" and the mime type in the header "Content-Type".
#Create a new media file for a asset or a record
Available since client version: 5.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFileCode = $client->getAssetMediaFileApi()->create('/tmp/allie_jean_model_picture.png');
#PAM - Deprecated
With the introduction of our brand new way to handle assets, the Asset Manager, the PAM feature will be removed from the v4.0 of the PIM. As a result, all the methods regarding the PAM assets are now deprecated.
To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, don't hesitate to take a look at the Asset Manager documentation to discover this new feature and how much more efficient it will be to handle your precious assets.
#Asset category - Deprecated
This resource is deprecated. It means that it may be removed in a future version of the PHP client. To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, did you know that since the PIM 3.2 (or the 5.0 of the client), you can handle your assets thanks to the Asset Manager, the brand new efficient way to manage your product assets within the PIM. In the Asset Manager, categories can be modelized thanks to a single or multiple options attribute in your asset family.
Eager to know more about the Asset Manager? It's right here!
#Get an asset category
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'face',
* 'parent' => 'images',
* 'labels' => [
* 'en_US' => 'Front picture',
* 'fr_FR' => 'Image de face',
* ],
* ]
*/
$assetCategory = $client->getAssetCategoryApi()->get('face');
#Get a list of asset categories
Available since client version: 2.0 | Only available for PIM EE
There are two ways of getting asset categories.
By getting pages
This method allows to get asset categories page per page, as a classical pagination. It's possible to get the total number of asset categories with this method.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAssetCategoryApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the asset categories. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$assetCategories = $client->getAssetCategoryApi()->all(50);
You can get more information about this method here.
#Upsert an asset category
Available since client version: 2.0 | Only available for PIM EE
If the asset category does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetCategoryApi()->upsert('dos', [
'parent' => 'images',
'labels' => [
'en_US' => 'Back picture',
'fr_FR' => 'Image de dos',
],
]);
#Upsert a list of asset categories
Available since client version: 2.0 | Only available for PIM EE
This method allows to create or update a list of asset categories.
It has the same behavior as the upsert
method for a single asset category, except that the code must be specified in the data of each asset category.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetCategoryApi()->upsertList([
[
'code' => 'dos',
'parent' => 'images',
'labels' => [
'en_US' => 'Back picture',
'fr_FR' => 'Image de dos',
],
],
[
'code' => 'face',
'parent' => 'images',
'labels' => [
'en_US' => 'Front picture',
'fr_FR' => 'Image de face',
],
],
]);
There is a limit on the maximum number of asset categories that you can upsert in one time on server side. By default this limit is set to 100.
#Asset reference file - Deprecated
This resource is deprecated. It means that it may be removed in a future version of the PHP client. To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, did you know that since the PIM 3.2 (or the 5.0 of the client), you can handle your assets thanks to the Asset Manager, the brand new efficient way to manage your product assets within the PIM. In the Asset Manager, asset reference files can be modelized thanks to media file attributes in your asset family.
Eager to know more about the Asset Manager? It's right here!
#Get a reference file of a localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'a/7/7/d/a77d13fb0e661587aec8ce81d479627e3ff467f4_chicago_skyline.jpg',
* 'locale' => 'en_US',
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/chicagoskyline/reference-files/en_US/download',
* ],
* ],
* ]
*/
$product = $client->getAssetReferenceFileApi()->getFromLocalizableAsset('chicagoskyline', 'en_US');
#Get a reference file of a not localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'b/7/b/e/b7be03a438ace1d9ea782440f735a72fff2a3f3c_bridge.jpg',
* 'locale' => null,
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/reference-files/no-locale/download',
* ],
* ],
* ]
*/
$product = $client->getAssetReferenceFileApi()->getFromNotLocalizableAsset('bridge');
#Download a reference file of a localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$product = $client->getAssetReferenceFileApi()->downloadFromLocalizableAsset('chicagoskyline', 'en_US');
file_put_contents('/tmp/chicagoskyline.jpg', $product->getContents());
From the v4 of the PHP client, the response is returned instead of the content. It allows getting the filename and the MIME type from the response. You can get the content this way:
file_put_contents('/tmp/chicagoskyline.jpg', $product->getBody()->getContents());
#Download a reference file of a not localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$product = $client->getAssetReferenceFileApi()->downloadFromNotLocalizableAsset('bridge');
file_put_contents('/tmp/bridge.jpg', $product->getContents());
From the v4 of the PHP client, the response is returned instead of the content. It allows getting the filename and the MIME type from the response. You can get the content this way:
file_put_contents('/tmp/bridge.jpg', $product->getBody()->getContents());
#Upload an asset reference file for a localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetReferenceFileApi()->uploadForLocalizableAsset('/tmp/chicagoskyline.jpg', 'chicagoskyline', 'en_US');
It will also automatically generate all the variation files corresponding to this reference file. If one or more generations of variation files failed, a specific exception will be thrown. You'll be able to see the details of the errors from this exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
try {
$client->getAssetReferenceFileApi()->uploadForLocalizableAsset('/tmp/chicagoskyline.jpg', 'chicagoskyline', 'en_US');
} catch(UploadAssetReferenceFileErrorException $exception) {
$uploadErrors = $exception->getErrors();
}
/*
* Example of errors:
*
* [
* 0 => [
* 'message' => 'Impossible to "scale" the image "Ziggy.jpg" with a width bigger than the original.',
* 'scope' => 'mobile',
* 'locale' => 'en_US',
* ],
* 1 => [
* 'message' => 'Impossible to "resize" the image "Ziggy.jpg" with a width bigger than the original.',
* 'scope' => 'print',
* 'locale' => 'en_US',
* ]
* ]
*/
#Upload an asset reference file for a not localizable asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetReferenceFileApi()->uploadForNotLocalizableAsset('/tmp/bridge.jpg', 'bridge');
It will also automatically generate all the variation files corresponding to this reference file. If one or more generation of variation file failed, a specific exception will be thrown. You'll be able to see the details of the errors from this exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
try {
$client->getAssetReferenceFileApi()->uploadForNotLocalizableAsset('/tmp/bridge.jpg', 'bridge');
} catch(UploadAssetReferenceFileErrorException $exception) {
$uploadErrors = $exception->getErrors();
}
/*
* Example of error:
*
* [
* 'message' => 'Impossible to "scale" the image "Ziggy.jpg" with a width bigger than the original.',
* 'scope' => 'mobile',
* 'locale' => null,
* ]
*/
#Asset tag - Deprecated
This resource is deprecated. It means that it may be removed in a future version of the PHP client. To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, did you know that since the PIM 3.2 (or the 5.0 of the client), you can handle your assets thanks to the Asset Manager, the brand new efficient way to manage your product assets within the PIM. In the Asset Manager, tags can be modelized thanks to a single or multiple options attribute in your asset family.
Eager to know more about the Asset Manager? It's right here!
#Get an asset tag
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'water',
* ]
*/
$assetTag = $client->getAssetTagApi()->get('water');
#Get a list of asset tags
Available since client version: 2.0 | Only available for PIM EE
There are two ways of getting asset tags.
By getting pages
This method allows to get asset tags page per page, as a classical pagination.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAssetTagApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the asset tags. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$assetTags = $client->getAssetTagApi()->all(50);
You can get more information about this method here.
#Upsert an asset tag
Available since client version: 2.0 | Only available for PIM EE
If the asset tag does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetTagApi()->upsert('cat');
#Asset variation file - Deprecated
This resource is deprecated. It means that it may be removed in a future version of the PHP client. To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, did you know that since the PIM 3.2 (or the 5.0 of the client), you can handle your assets thanks to the Asset Manager, the brand new efficient way to manage your product assets within the PIM. In the Asset Manager, asset variation files can be modelized thanks to a media file attributes in your asset family.
Eager to know more about the Asset Manager? It's right here!
#Get a variation file of a localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'f/5/5/c/f55c7ea4adae17d4e02f4d04a839bc2a7cdbf165_chicago_skyline_en_US_mobile.jpg',
* 'locale' => 'en_US',
* 'scope' => 'mobile',
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/chicagoskyline/variation-files/mobile/en_US/download',
* ],
* ],
* ]
*/
$product = $client->getAssetVariationFileApi()->getFromLocalizableAsset('chicagoskyline', 'mobile', 'en_US');
#Get a variation file of a not localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => '0/7/2/1/07217eea32563821b46336d2dec696e4f69415ec_bridge_mobile.jpg',
* 'locale' => null,
* 'scope' => 'mobile',
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/variation-files/mobile/no-locale/download',
* ],
* ],
* ]
*/
$product = $client->getAssetVariationFileApi()->getFromNotLocalizableAsset('bridge', 'mobile');
#Download a variation file of a localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$product = $client->getAssetVariationFileApi()->downloadFromLocalizableAsset('chicagoskyline', 'mobile', 'en_US');
file_put_contents('/tmp/chicagoskyline-mobile.jpg', $product->getContents());
From the v4 of the PHP client, the response is returned instead of the content. It allows getting the filename and the MIME type from the response. You can get the content this way:
file_put_contents('/tmp/chicagoskyline-mobile.jpg', $product->getBody()->getContents());
#Download a variation file of a not localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$product = $client->getAssetVariationFileApi()->downloadFromNotLocalizableAsset('bridge', 'mobile');
file_put_contents('/tmp/bridge-mobile.jpg', $product->getContents());
From the v4 of the PHP client, the response is returned instead of the content. It allows getting the filename and the MIME type from the response. You can get the content this way:
file_put_contents('/tmp/bridge-mobile.jpg', $product->getBody()->getContents());
#Upload an asset variation file for a localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetVariationFileApi()->uploadForLocalizableAsset('/tmp/chicagoskyline-mobile.jpg', 'chicagoskyline', 'mobile','en_US');
#Upload an asset variation file for a not localizable asset
Available since client version: 2.0
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetVariationFileApi()->uploadForNotLocalizableAsset('/tmp/bridge-mobile.jpg', 'bridge', 'mobile');
#Asset - Deprecated
This resource is deprecated. It means that it may be removed in a future version of the PHP client. To understand why, we recommend you to read this Medium post, we wrote on this special occasion.
Also, did you know that since the PIM 3.2 (or the 5.0 of the client), you can handle your assets thanks to the Asset Manager, the brand new efficient way to manage your product assets within the PIM.
Eager to know more about these new assets? It's right here!
#Get an asset
Available since client version: 2.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'bridge',
* 'localizable' => false,
* 'description' => 'Architectural bridge of a city, above water',
* 'end_of_use' => '2028-01-25T00:00:00+00:00',
* 'tags' => [
* 'cities',
* 'water',
* ],
* 'categories' => [
* 'faces',
* ],
* 'variation_files' => [
* [
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/variation-files/mobile/no-locale/download',
* ],
* 'self' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/variation-files/mobile/no-locale',
* ],
* ],
* 'locale' => null,
* 'scope' => 'mobile',
* 'code' => '0/7/2/1/07217eea32563821b46336d2dec696e4f69415ec_bridge_mobile.jpg',
* ],
* [
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/variation-files/ecommerce/no-locale/download',
* ],
* 'self' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/variation-files/ecommerce/no-locale',
* ],
* ],
* 'locale' => null,
* 'scope' => 'ecommerce',
* 'code' => 'a/e/1/0/ae104d0b8cd2111380029240630008a01585d7ed_bridge_ecommerce.jpg',
* ],
* ],
* 'reference_files' => [
* [
* '_link' => [
* 'download' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/reference-files/no-locale/download',
* ],
* 'self' => [
* 'href' => 'http://akeneo.com/api/rest/v1/assets/bridge/reference-files/no-locale',
* ],
* ],
* 'locale' => null,
* 'code' => 'b/7/b/e/b7be03a438ace1d9ea782440f735a72fff2a3f3c_bridge.jpg',
* ],
* ],
* ]
*/
$asset = $client->getAssetApi()->get('bridge');
#Get a list of assets
Available since client version: 2.0 | Only available for PIM EE
There are two ways of getting assets.
By getting pages
This method allows to get assets page per page, as a classical pagination. It's possible to get the total number of assets with this method.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$firstPage = $client->getAssetApi()->listPerPage(50, true);
You can get more information about this method here.
With a cursor
This method allows to iterate the assets. It will automatically get the next pages for you.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$assets = $client->getAssetApi()->all(50);
You can get more information about this method here.
#Create an asset
Available since client version: 2.0 | Only available for PIM EE
If the asset does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/', 'client_id', 'secret', 'admin', 'admin')->build()
$client->getAssetApi()->create('unicorn', [
'localizable' => false,
'description' => 'The wonderful unicorn',
'end_of_use' => '2042-11-21',
'tags' => ['colored', 'flowers'],
'categories' => ['face', 'pack'],
]);
#Upsert an asset
Available since client version: 2.0 | Only available for PIM EE
If the asset does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetApi()->upsert('bridge', [
'localizable' => false,
'description' => 'Architectural bridge of a city, above water',
'end_of_use' => null,
'tags' => ['water'],
'categories' => ['face', 'pack']
]);
#Upsert a list of assets
Available since client version: 2.0 | Only available for PIM EE
This method allows to create or update a list of assets.
It has the same behavior as the upsert
method for a single asset, except that the code must be specified in the data of each asset.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAssetApi()->upsertList([
[
'code' => 'unicorn',
'localizable' => false,
'description' => 'The wonderful unicorn',
'end_of_use' => '2042-11-21',
'tags' => ['colored', 'flowers'],
'categories' => ['face', 'pack'],
],
[
'code' => 'bridge',
'localizable' => false,
'description' => 'Architectural bridge of a city, above water',
'end_of_use' => null,
'tags' => ['water'],
'categories' => ['face', 'pack']
],
]);
There is a limit on the maximum number of assets that you can upsert in one time on server side. By default this limit is set to 100.
#Reference entities
#Reference entity
#Get a reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'brand',
* 'labels' => [
* 'en_US' => 'Brand',
* 'fr_FR' => 'Marque',
* ],
* 'image' => '5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg',
* '_links' => [
* 'image_download' => [
* 'href' => 'http://localhost:8080/api/rest/v1/reference-entities-media-files/5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg',
* ],
* ],
* ]
*/
$referenceEntity = $client->getReferenceEntityApi()->get('brand');
#Get the list of the reference entities
Available since client version: 4.0 | Only available for PIM EE
You can get more information about the available query parameters here.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$referenceEntitiesCursor = $client->getReferenceEntityApi()->all();
#Upsert a reference entity
Available since client version: 4.0 | Only available for PIM EE
If the reference entity does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getReferenceEntityApi()->upsert('brand', [
'code' => 'brand',
'labels' => [
'en_US' => 'Brand',
'fr_FR' => 'Marque',
],
'image' => '5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg'
]);
#Reference entity attribute option
#Get an attribute option for a given attribute of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'red',
* 'labels' => [
* 'en_US' => 'Red',
* 'fr_FR' => 'Rouge',
* ]
* ]
*/
$referenceEntityAttributeOption = $client->getReferenceEntityAttributeOptionApi()->get('designer', 'favorite_color', 'red');
#Get the list of attribute options of a given attribute for a given reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$referenceEntityAttributeOptions = $client->getReferenceEntityAttributeOptionApi()->all('designer', 'favorite_color');
#Upsert an attribute option for a given attribute of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
If the attribute option does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getReferenceEntityAttributeOptionApi()->upsert('designer', 'favorite_color', 'blue', [
'code' => 'blue',
'labels' => [
'en_US' => 'Blue',
'fr_FR' => 'Bleu',
]
]);
#Reference entity attribute
#Get an attribute of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'description',
* 'labels' => [
* 'en_US' => 'Description',
* 'fr_FR' => 'Description',
* ],
* 'type' => 'text',
* 'localizable' => true,
* 'scopable' => true,
* 'is_required_for_completeness' => true,
* 'max_characters' => null,
* 'is_textarea' => true,
* 'is_rich_text_editor' => true,
* 'validation_rule' => 'none',
* 'validation_regexp' => null,
* ]
*/
$referenceEntityAttribute = $client->getReferenceEntityAttributeApi()->get('brand', 'description');
#Get the list of attributes of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$referenceEntityRecordsCursor = $client->getReferenceEntityAttributeApi()->all('brand');
#Upsert an attribute of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
If the attribute does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getReferenceEntityAttributeApi()->upsert('brand', 'description', [
'code' => 'description',
'labels' => [
'en_US' => 'Description'
],
'type' => 'text',
'value_per_locale' => true,
'value_per_channel' => true,
'is_required_for_completeness' => false
]);
#Reference entity media file
#Download the media file associated to a reference entity or a record
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFileResponse = $client->getReferenceEntityMediaFileApi()->download('images/kartell.png');
From the response, you can retrieve the file name in the header "Content-Disposition" and the mime type in the header "Content-Type".
#Create a new media file for a reference entity or a record
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$mediaFileCode = $client->getReferenceEntityMediaFileApi()->create('/tmp/kartell.png');
#Reference entity record
#Get a record of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like this:
* [
* 'code' => 'kartell',
* 'values' => [
* 'labels' => [
* [
* 'locale' => 'en_US',
* 'channel' => null,
* 'data' => 'Kartell',
* ],
* ],
* 'image' => [
* [
* 'locale' => null,
* 'channel' => null,
* 'data' => '0/c/b/0/0cb0c0e115dedba676f8d1ad8343ec207ab54c7b_image.jpg',
* ],
* ],
* 'description' => [
* [
* 'locale' => 'en_US',
* 'channel' => null,
* 'data' => 'Kartell, the Italian furniture company that sells modern and remarkable pieces of furnitures.',
* ],
* [
* 'locale' => 'fr_FR',
* 'channel' => null,
* 'data' => 'Kartell, l\'éditeur de meuble italien spécialisé dans la signature de belle pièces au design contemporain.',
* ],
* ],
* 'designer' => [
* [
* 'locale' => null,
* 'channel' => null,
* 'data' => 'starck',
* ],
* ],
* ],
* ];
*
*/
$referenceEntityRecord = $client->getReferenceEntityRecordApi()->get('brand', 'kartell');
#Get the list of the records of a reference entity
Available since client version: 4.0 | Only available for PIM EE
Records are automatically paginated and can be filtered.
You can get more information about the available query parameters here.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$referenceEntityRecordsCursor = $client->getReferenceEntityRecordApi()->all('brand');
#Upsert a record of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
If the record does not exist yet, this method creates it, otherwise it updates it.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getReferenceEntityRecordApi()->upsert('brand', 'kartell', [
'code' => 'kartell',
'values' => [
'label' => [
[
'channel' => null,
'locale' => 'en_US',
'data' => 'Kartell'
],
],
'designer' => [
[
'locale' => null,
'channel' => null,
'data' => 'starck',
],
],
]
]);
#Upsert a list of records of a given reference entity
Available since client version: 4.0 | Only available for PIM EE
This method allows to create or update a list of records of a given reference entity.
It has the same behavior as the upsert
method for a single record.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getReferenceEntityRecordApi()->upsertList('brand', [
[
'code' => 'kartell',
'values' => [
'label' => [
[
'channel' => null,
'locale' => 'fr_FR',
'data' => 'Kartell'
],
]
]
],
[
'code' => 'lexon',
'values' => [
'label' => [
[
'channel' => null,
'locale' => 'en_US',
'data' => 'Lexon'
],
]
]
]
]);
#Catalogs for Apps
#App catalog
#Get the list of owned catalogs
Available since client version: 9.1
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('https://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like the following:
* [
* {
* "id": "12351d98-200e-4bbc-aa19-7fdda1bd14f2",
* "name": "Store FR",
* "enabled": true
* },
* {
* "id": "12351d98-200e-4bbc-aa19-7fdda1bd14f3",
* "name": "Store US",
* "enabled": true
* }
* ]
*/
$catalogs = $client->getAppCatalogApi()->all();
#Get a catalog
Available since client version: 9.1
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('https://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an object like the following :
* {
* "id": "12351d98-200e-4bbc-aa19-7fdda1bd14f2",
* "name": "Store FR",
* "enabled": true
* }
*/
$catalogs = $client->getAppCatalogApi()->get('12351d98-200e-4bbc-aa19-7fdda1bd14f2');
#Create a new catalog
Available since client version: 9.1
If the catalog does not exist yet, this method creates it, otherwise it throws an exception.
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAppCatalogApi()->create(['name' => 'A catalog name']);
#Update a catalog
Available since client version: 9.1
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAppCatalogApi()->upsert(['name' => 'A catalog name']);
#Delete a catalog
Available since client version: 9.1
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
$client->getAppCatalogApi()->delete('12351d98-200e-4bbc-aa19-7fdda1bd14f2');
#App catalog product
#Get the list of product uuids
Available since client version: 9.1
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('https://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
/*
* Returns an array like the following:
* [
* "844c736b-a19b-48a6-a354-6056044729f0",
* "b2a683ef-4a91-4ed3-b3fa-76dab065a8d5",
* "eddfbd2a-abc7-488d-b9e3-41289c824f80"
* ]
*/
$catalogs = $client->getAppCatalogProductApi()->all();