Api for getting and sending data to webareal type eshops
Full documentation here
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist matejch/webareal-api-handler "^1.0"
or add
"matejch/webareal-api-handler": "^1.0"
to the require section of your composer.json
file.
You need username, password and token (API key) from your webareal eshop API key is located in tab API
Token bearer for requests is retrieved in login request
All classes extend from \matejch\webarealApiHandler\WebarealHandler
/** create handler, constructor requires username, password, adn token */
/** all can be acquired from your webareal admin interface */
$handler = new \matejch\webarealApiHandler\WebarealHandler($username,$password,$apiToken);
/** New handler instance can be also created with json file, that contains username, password, apiKey and url(optional) */
$handler = \matejch\webarealApiHandler\WebarealHandler::createFromFile('path_to_the_json_file');
/** login before other requests */
$handler->login();
/** this is function for testing successful login, returns message whether access was granted */
$handler->test();
/**
* You can check info about how many request you have remaining,
* what's your limit and whether you are blocked
*/
$handler->apiInfo()
/** API subdomain */
/** If you don't use subdomain set in class use this method*/
$handler->setBaseUrl($apiSubDomainUrl);
Info about customers endpoint here
/** Only one api endpoint exists, and that is for getting list of customers */
$customers = new \matejch\webarealApiHandler\WCustomers($username,$password,$apiToken);
$customers->login();
$customers->asArray = true; // optional
/** also query string for searching specific customers can be set*/
$customers->searchBy(['limit' => 20,
'offset' => 0,
'sortBy' => 'id',
'sortDirection' => 'desc',
'findBy' => 'id',
'searchedString' => 'search string here']);
/** data can be returned as json string or array of customers */
$customers->get();
Info about product endpoints here
/**For mass update use */
function setFieldsAsString(array_of_products)
$products = new \matejch\webarealApiHandler\WProduct($username,$password,$apiToken);
$products->login();
$products->asArray = true; // optional
/** get list of products */
/** filter can be set with $products->searchBy(array of searchable options) */
$products->get();
/**
* id of product necessary for update, delete, view can be obtained with get() method,
* or through csv from your admin interface
*/
/** create new product */
$products->setFields(['name' => 'Name', ....]);
$products->create();
/** update existing product, you must know id beforehand */
$products->setFields(['secondName' => 'Second', ....]);
$products->update($id);
/** delete existing product, you must know id beforehand */
$products->delete($id);
/** detail info about one product, you must know id beforehand */
$products->view($id);
/** update and create multiple products at once */
$products->setFields(['name' => 'product', ....]);
$products->createMultiple();
/** to update multiple product id is required for every product */
$products->updateMultiple();
Info about order endpoints here
$orders = new \matejch\webarealApiHandler\WOrder($username,$password,$apiToken);
$orders->login();
$orders->get();
$orders->states();
$orders->view($id);
$products->setFields(['firstname' => 'Jane', 'lastname' => 'Doe',...]);
$orders->update($id);
$orders->delete($id)
Info product properties endpoints here
$property = new \matejch\webarealApiHandler\WProductProperty($username,$password,$apiToken);
$property->login();
$property->get();
$property->view($id);
$property->setFields(['name' => 'Color']);
$property->create($id);
/** before calling update, setFields must set fields you want to update on property */
$property->setFields(['name' => 'Color']);
$property->update($id);
/** delete property */
$property->delete($id);
/** create and update multiple */
$property->setFields(['name' => 'Color']);
$property->createMultiple();
/** id for every property must be set when updating */
$property->updateMultiple();
Info product variants endpoints here
/** Product variants are products connected to other product */
$variants = new \matejch\webarealApiHandler\WProductVariants($username,$password,$apiToken);
$variants->login();
/** get list of variants, can be search by using searchBy method */
$variants->get();
$variants->view($id);
/** before calling create, setFields must set fields you want to update on property */
$variants->setFields(['idProduct' => 9,'name' => 'Jacket']);
$variants->create($id);
/** before calling update, setFields must set fields you want to update on property */
$variants->setFields(['idProduct' => 9,'name' => 'Jacket']);
$variants->update($id);
/** delete property */
$variants->delete($id);
/** create and update multiple */
$variants->setFields(['name' => 'Color']);
$variants->createMultiple();
/** id for every variant must be set when updating */
$variants->updateMultiple();
- Login request
- Test request
- Api info
- Get customers
- Get products
- Create product
- Get product info
- Remove product
- Update product
- Create multiple products
- Update multiple products
- Create properties
- Update properties
- Get property
- Update property
- Remove property
- Get property list
- Create product variant
- Get product variants list
- Get product variant
- Create product variants
- Update product variants
- Get product variant list
- Update product variant list
- Remove product variant
- Get property values list
- Create property values
- Create property value
- Get property value info
- Remove specific property value
- Update specific property value
- Get order list
- Update orders
- Get order info
- Update order
- Remove order
- Get all order states
- Update order products
- Update order product
- Remove order product