PHPackages                             nhupham-commonservices/spartoo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nhupham-commonservices/spartoo

ActiveLibrary[API Development](/categories/api)

nhupham-commonservices/spartoo
==============================

A wrapper for the Spartoo API.

1.0.9(3w ago)0112MITPHP

Since Jun 16Pushed 3w agoCompare

[ Source](https://github.com/nhupham-commonservices/spartoo)[ Packagist](https://packagist.org/packages/nhupham-commonservices/spartoo)[ RSS](/packages/nhupham-commonservices-spartoo/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)DependenciesVersions (10)Used By (0)

Spartoo API (Fork a repo)
=========================

[](#spartoo-api-fork-a-repo)

Implementation of the [Spartoo](https://spartoo.com) API.
This API allows you to :

- Import products
- Quickly update stock
- Quickly update stock in batch
- Export online catalog
- Check product status
- Export orders
- Update orders
- Export delivery slips
- Export returns
- Update returns

Installation
------------

[](#installation)

It is recommended to use [composer](https://getcomposer.org/) to install the package :

```
$ composer require nhupham-commonservices/spartoo

```

**PHP 7.2 or newer is required.**

Usage
-----

[](#usage)

First of all you need your Merchant ID for webservices to use the API.
It is available on [your seller account](https://www.spartoo.fr/mp/informations.php), then you can instantiate the app :

```
require_once __DIR__.'/vendor/autoload.php';

$app = new Spartoo\App('EF40F969744AF620');
```

*Every method of Spartoo\\App return an instance of `SimpleXMLElement` containing the response from Spartoo.*

### Create products

[](#create-products)

```
require_once __DIR__.'/vendor/autoload.php';

use Spartoo\App;
use Spartoo\Factory;

$app = new App('EF40F969744AF620');

$products = [
    Factory::getProduct('98', 'ALL STAR HI', 'Converse', 64.99)
        ->setProductSex('M')
        ->setProductQuantity(5)
        ->setColorId(8)
        ->setProductStyle(10059)
        ->setProductDescription(
            'Mythique parmi les mythiques, la Chuck Taylor All Star de Converse est une incontournable. Ici en version montante avec une tige en toile et un imprimé uni classique, elle se la joue intemporelle et indémodable !'
        )
        ->setProductColor('Rouge')
        ->setSizeList([
            Factory::getSize('38', 4, '98_38', '123456789011'),
            Factory::getSize('39', 1, '98_39', '123456789012')
        ])
        ->setProductComposition(1)
        ->setPhotos([
            'https://imgext.spartoo.com/photos/98/98/98_350_A.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_B.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_C.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_D.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_E.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_F.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_G.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_H.jpg'
        ])
        ->setDiscount(Factory::getDiscount(
            time(),
            time() + 60 * 60 * 24 * 31,
            null,
            20,
            false
        )),
    // Other products ...
];

$app->importProducts($products);
```

### Create multi country products

[](#create-multi-country-products)

```
require_once __DIR__.'/vendor/autoload.php';

use Spartoo\App;
use Spartoo\Factory;

$app = new App('EF40F969744AF620');

$products = [
    Factory::getProductMultiCountry([
            Factory::getLanguage(
                'FR',
                'ALL STAR HI',
                'Mythique parmi les mythiques, la Chuck Taylor All Star de Converse est une incontournable. Ici en version montante avec une tige en toile et un imprimé uni classique, elle se la joue intemporelle et indémodable !',
                'Rouge',
                64.99
            ),
            Factory::getLanguage(
                'ES',
                'ALL STAR HI',
                'Mítico entre los míticos, el Chuck Taylor All Star of Converse es un must have. Aquí, en una versión ascendente con un tallo de lienzo y una impresión lisa clásica, ¡es intemporal y atemporal!',
                'Rojo',
                64.99
            ),
        ], 'Converse')
        ->setReferencePartenaire('98')
        ->setProductSex('M')
        ->setProductQuantity(5)
        ->setColorId(8)
        ->setProductStyle(10059)
        ->setSizeList([
            Factory::getSize('38', 4, '98_38', '123456789011'),
            Factory::getSize('39', 1, '98_39', '123456789012')
        ])
        ->setProductComposition(1)
        ->setPhotos([
            'https://imgext.spartoo.com/photos/98/98/98_350_A.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_B.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_C.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_D.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_E.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_F.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_G.jpg',
            'https://imgext.spartoo.com/photos/98/98/98_350_H.jpg'
        ]),
    // Other multi country products ...
];

$app->importProducts($products);
```

### Quickly update a product

[](#quickly-update-a-product)

```
$partner_reference = 'demo_01';
$product_size_reference = 'demo_01_01';
$quantity = 42;

$app->majStock($partner_reference, $product_size_reference, $quantity);
```

### Quickly update products in batch

[](#quickly-update-products-in-batch)

```
$products = [
    Factory::getProduct('98', 'ALL STAR HI', 'Converse', 64.99)
            ->setSizeList([
                Factory::getSize('38', 4, '98_38'),
                Factory::getSize('39', 1, '98_39')
            ]),
    Factory::getProduct('99', 'Continental', 'Adidas', 90.99)
            ->setSizeList([
                Factory::getSize('40', 12, '99_40'),
                Factory::getSize('41', 3, '99_41')
            ]),
    // Other products ...
];

$app->majStockBatch($products);
```

### Export products in catalog

[](#export-products-in-catalog)

```
$products = $app->exportProducts();
```

### Check products status

[](#check-products-status)

```
$products = [
    Factory::getProduct('98', 'ALL STAR HI', 'Converse', 64.99)
            ->setSizeList([
                Factory::getSize('38', 4, '98_38'),
                Factory::getSize('39', 1, '98_39')
            ]),
    Factory::getProduct('99', 'Continental', 'Adidas', 90.99)
            ->setSizeList([
                Factory::getSize('40', 12, '99_40'),
                Factory::getSize('41', 3, '99_41')
            ]),
    // Other products ...
];

$results = $app->checkStatusProducts($products);
```

### Export orders list

[](#export-orders-list)

```
$orders = $app->exportOrders(new DateTime('2020-03-01'));
```

### Export delivery slip

[](#export-delivery-slip)

```
$product = Factory::getProduct('98', 'ALL STAR HI', 'Converse', 64.99)
    ->setProductQuantity(1);

$delivery_slip = $app->exportBL('my_order_id', $product);
```

### Export returns

[](#export-returns)

```
$returns = $app->exportReturns(new DateTime('2020-03-01'));
```

### Update a return

[](#update-a-return)

```
$app->majReturns('return_id', 3, 'https://example.com/my/return/label.pdf');
```

### Provisionning

[](#provisionning)

You can get provisionning data from the `Provionning` class, default language is french but you can set an other one or switch to another one.

```
require_once __DIR__ . '/vendor/autoload.php';

use Spartoo\Provisionning;

var_dump(
    Provisionning::getInstance()->getLanguages(),
    Provisionning::getInstance()->getProductsSex(),
    Provisionning::getInstance()->getColors(),
    Provisionning::getInstance()->switchLanguage('IT')->getColors(),
    Provisionning::getInstance()->switchLanguage('ES')->getColors(),
    Provisionning::getInstance()->switchLanguage('FR')->getCompositions(),
    Provisionning::getInstance()->getCategories(),
    Provisionning::getInstance()->getSelections(),
    Provisionning::getInstance()->getExtraInfos(),
    Provisionning::getInstance()->getOrdersStatus(),
    Provisionning::getInstance()->getReturnsStatus(),
    Provisionning::getInstance()->getSizes(),
    Provisionning::getInstance()->getCurrencies(),
    Provisionning::getInstance()->getInvoiceTypes(),
    Provisionning::getInstance()->getProductStyles()
);
```

### Maintaining provisionning data

[](#maintaining-provisionning-data)

Bundled reference data lives in `src/XML/{lang}_xml_provisionning.zip` and is read by `Provisionning.php`.

To refresh all locales from Spartoo live URLs:

```
php scripts/update-provisionning-zips.php
php scripts/verify-provisionning-zips.php
```

Update a subset of languages only:

```
php scripts/update-provisionning-zips.php fr en de
```

Remove stray `*.xml` files from `src/XML/` (only zip files belong in the repo):

```
php scripts/update-provisionning-zips.php --clean-only
```

### Format / backward compatibility

[](#format--backward-compatibility)

Generated zips match what `Provisionning.php` expects:

- Path: `src/XML/{lang}_xml_provisionning.zip`
- Single entry inside the zip: `{lang}_xml_provisionning.xml`
- XML root: `` with UTF-8 declaration, LF line endings, no BOM
- Required sections: `products_sex`, `colors`, `compositions`, `categories`, `extra_info`, `orders_status`, `returns_status`, `sizes`, `languages`, `currencies`, `invoice_types`

`verify-provisionning-zips.php` rejects downloads that do not match this structure. Spartoo’s live feed may omit `` (present in older bundled files); that is logged as a warning — `getSelections()` then returns an empty list, which matches Spartoo’s current reference data.

After updating, commit `src/XML/`, bump the package version in `CHANGELOG`, tag a release, then run `composer update nhupham-commonservices/spartoo` in consuming apps.

Requires PHP **ext-zip** and **ext-simplexml**.

License
-------

[](#license)

The package is licensed under the MIT license. See [License File](https://github.com/debuss/spartoo/blob/master/LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance95

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~141 days

Recently: every ~195 days

Total

8

Last Release

23d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/110216013?v=4)[Nhu Pham](/maintainers/nhupham-commonservices)[@nhupham-commonservices](https://github.com/nhupham-commonservices)

![](https://avatars.githubusercontent.com/u/166588587?v=4)[Lê Đức Tâm](/maintainers/ceres-ductamle)[@ceres-ductamle](https://github.com/ceres-ductamle)

---

Top Contributors

[![nhupham-commonservices](https://avatars.githubusercontent.com/u/110216013?v=4)](https://github.com/nhupham-commonservices "nhupham-commonservices (15 commits)")[![tran-cs](https://avatars.githubusercontent.com/u/65382487?v=4)](https://github.com/tran-cs "tran-cs (3 commits)")[![ceres-ductamle](https://avatars.githubusercontent.com/u/166588587?v=4)](https://github.com/ceres-ductamle "ceres-ductamle (2 commits)")[![nhupham-intersoft](https://avatars.githubusercontent.com/u/127480975?v=4)](https://github.com/nhupham-intersoft "nhupham-intersoft (1 commits)")

### Embed Badge

![Health badge](/badges/nhupham-commonservices-spartoo/health.svg)

```
[![Health](https://phpackages.com/badges/nhupham-commonservices-spartoo/health.svg)](https://phpackages.com/packages/nhupham-commonservices-spartoo)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
