PHP API client documentation

#Resources

#Catalog modeling entities

#Association type

#Get an association type

$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',
 *      ],
 * ]
 */
$associationType = $client->getAssociationTypeApi()->get('X_SELL');

#Get a list of association types

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

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

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

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

$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

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

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

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

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

$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

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

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

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

Only available since the version 2.0 of the PHP API client.

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([
    [
        'code'       => 'black',
        'attribute'  => 'a_simple_select',
        'sort_order' => 2,
        'labels'     => [
            'en_US' => 'Black',
            'fr_FR' => 'Noir',
        ]
    ],
    [
        'code'       => 'white',
        'attribute'  => 'a_simple_select',
        '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

$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'],
 *     ]
 * ]
 */
$attribute = $client->getAttributeApi()->get('release_date');

#Get a list of attributes

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

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'],
     ]
]);

#Upsert an attribute

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'],
     ]
]);

#Upsert a list of attributes

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'],
         ]
    ],
    [
        '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

$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

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

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

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

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.

#Channel

#Get a channel

$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

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

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

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

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.

#Family

#Get a family

$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

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

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

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

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

$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

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

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

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

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.

#Global settings entities

#Currency

#Get a currency

$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

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

$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('ecommerce');

#Get a list of locales

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

#Get a measure family

$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

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.

#Media resources entities

#Asset category

This resource is only available in the Entreprise Edition.

This resource is only available since the version 2.0 of the PHP API client.

#Get an asset category

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

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\AkeneoPimEnterpriseClientBuilder('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\AkeneoPimEnterpriseClientBuilder('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

If the asset category does not exist yet, this method creates it, otherwise it updates it.

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

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\AkeneoPimEnterpriseClientBuilder('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

This resource is only available in the Entreprise Edition.

This resource is only available since the version 2.0 of the PHP API client.

#Get a reference file of a localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$product = $client->getAssetReferenceFileApi()->downloadFromLocalizableAsset('chicagoskyline', 'en_US');

file_put_contents('/tmp/chicagoskyline.jpg', $product->getContents());

#Download a reference file of a not localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$product = $client->getAssetReferenceFileApi()->downloadFromNotLocalizableAsset('bridge');

file_put_contents('/tmp/bridge.jpg', $product->getContents());

#Upload an asset reference file for a localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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\AkeneoPimEnterpriseClientBuilder('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

This resource is only available in the Entreprise Edition.

This resource is only available since the version 2.0 of the PHP API client.

#Get an asset tag

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

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\AkeneoPimEnterpriseClientBuilder('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\AkeneoPimEnterpriseClientBuilder('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

If the asset tag does not exist yet, this method creates it, otherwise it updates it.

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$client->getAssetTagApi()->upsert('cat');

#Asset variation file

This resource is only available in the Entreprise Edition.

This resource is only available since the version 2.0 of the PHP API client.

#Get a variation file of a localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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());

#Download a variation file of a not localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$product = $client->getAssetVariationFileApi()->downloadFromNotLocalizableAsset('bridge', 'mobile');

file_put_contents('/tmp/bridge-mobile.jpg', $product->getContents());

#Upload an asset variation file for a localizable asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$client->getAssetVariationFileApi()->uploadForNotLocalizableAsset('/tmp/bridge-mobile.jpg', 'bridge', 'mobile');

#Asset

This resource is only available in the Entreprise Edition.

This resource is only available since the version 2.0 of the PHP API client.

#Get an asset

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

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\AkeneoPimEnterpriseClientBuilder('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\AkeneoPimEnterpriseClientBuilder('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

If the asset does not exist yet, this method creates it, otherwise it throws an exception.

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

If the asset does not exist yet, this method creates it, otherwise it updates it.

$client = new \Akeneo\Pim\ApiClient\AkeneoPimEnterpriseClientBuilder('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

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\AkeneoPimEnterpriseClientBuilder('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.

#Media file

#Get media file information

$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

$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', $product->getContents());

#Get a list of media file information

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

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 entities

#Product

#Get a product

$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
 *              ],
 *              [
 *                  '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' => []
 *         ],
 *     ],
 * ]
 */
$product = $client->getProductApi()->get('top');

You can get more information about the returned format of the product values here.

In the 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.

#Get a list of products

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', '8', 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

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

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 Entreprise 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

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

$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');

$client->getProductApi()->delete('top');

#Product draft

This resource is only available in the Entreprise Edition.

#Get a product draft

$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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' => []
 *         ],
 *     ],
 *     '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.

#Submit a product draft for approval

$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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 model draft

This resource is only available in the Entreprise Edition and in the 3.0 version of the PHP API client.

#Get a product model draft

$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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',
 *             ]
 *         ],
 *     ],
 *     '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

$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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.

#Product model

#Get a product model

$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',
 *             ]
 *         ],
 *     ],
 *     '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 Enterprise Edition, the response contains one more field metadata. Look at the product model drafts for an example.

#Get a list of product models

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

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

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

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.

#Published product

This resource is only available in the Entreprise Edition.

#Get a published product

$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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.

#Get a list of published products

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\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('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.


Found a typo or a hole in the documentation and feel like contributing?
Join us on Github!