Mall marketplace API client
MPAPI client is a tool created to help Internet Mall partners to easily connect to marketplace catalogue and order processing at Mall environment such as Mall.cz or Mall.sk.
We recommend to use Composer. Once you have composer installed, you can execute the following command in your project root to get the mpapi-client library:
composer require mallgroup/mpapi-client
To check successful installation go to the vendor folder. You should see the mallgroup folder there. Be sure you include the autoloader:
To connect your shop by MPAPI client is made as easy as possible, however we expect some basic knowledge of PHP5. You will need to connect to all the services located in /vendor/mallgroup/mpapi/src/Services as shown in example files in /vendor/mallgroup/mpapi/Example. The services provide functions to receive data from Mall environment as well as send, update or delete data.
We use two different environments in Mall: testing and production. You will get two different client IDs for each environment so that you can test work with data without a risk of bad transactions at production.
You will need the client Id as a parameter for MPAPI client:
$mpapiClient = new Client('yourTestClientId');
MPAPI client has implemented a logger interface with a simple PSR logger for errors and all important events. It is up to you, if you decide to implement any ready-to-use logging library e.g. [monolog] (https://packagist.org/packages/monolog/monolog "https://packagist.org/packages/monolog/monolog") as shown in the example bellow or you will implement your own logging.
$logger = new Logger('yourLoggerName'); $logger->pushHandler(new StreamHandler('./elog.log', Logger::INFO)); $mpapiClient->setLogger($logger);
See more in /path/to/your-project/vendor/mallgroup/mpapi-client/Example/LoggerExample.php.
<?php use Monolog\Logger; use Monolog\Handler\StreamHandler; use MPAPI\Services\Client; use MPAPI\Services\NameOfService; // replace this with relevant service name // include your composer dependencies require __DIR__ . '/../vendor/autoload.php'; $mpapiClient = new Client('yourTestClientId'); $logger = new Logger('yourLoggerName'); $logger->pushHandler(new StreamHandler('./elog.log', Logger::INFO)); // set logger into MP API client $mpapiClient->setLogger($logger); // create instance of the required service $exampleService = new NameOfService($mpapiClient); ...
For more examples how to use specific services see following links:
- Products – create, update, delete or get data.
- Variants – create, update, delete or get data.
- Availability – update product or variant.
- Supply delay – create, update, delete or get supply delay for a product or variant.
- Orders - get information about specific order, get all order IDs of open or unconfirmed orders, change order status.
- Partner deliveries - get, create or update partner deliveries.
- Delivery pricing - get, create, update or delete delivery pricing levels.
- Labels - get list of available labels.
- Categories - get all categories, search title with phrase or prefix, get available parameters for specific category.
- Brands - get all brands, search title with phrase.
- Partner - manage partner supply delay.