Store
extends AbstractApiResourceGroup
in package
Class Store
Tags
Table of Contents
Methods
- inventories() : InventoriesResponse
- Makes GET "/api/v5/store/inventories" request.
- inventoriesUpload() : InventoriesUploadResponse
- Makes POST "/api/v5/store/inventories/upload" request.
- offers() : OffersResponse
- Makes GET "/api/v5/store/offers" request.
- pricesUpload() : PricesUploadResponse
- Makes POST "/api/v5/store/prices/upload" request.
- productBatchEdit() : ProductBatchEditResponse
- Makes POST "/api/v5/store/store/products/batch/edit" request.
- productGroups() : ProductGroupsResponse
- Makes GET "/api/v5/store/product-groups" request.
- productGroupsCreate() : IdResponse
- Makes POST "/api/v5/store/product-groups/create" request.
- productGroupsEdit() : IdResponse
- Makes POST "/api/v5/store/product-groups/{externalId}/edit" request.
- products() : ProductsResponse
- Makes GET "/api/v5/store/products" request.
- productsBatchCreate() : ProductsBatchCreateResponse
- Makes POST "/api/v5/store/products/batch/create" request.
- productsProperties() : ProductPropertiesResponse
- Makes GET "/api/v5/store/products/properties" request.
- productsPropertyValues() : ProductPropertyValuesResponse
- Makes GET "/api/v5/store/products/properties/values" request.
Methods
inventories()
Makes GET "/api/v5/store/inventories" request.
public
inventories([InventoriesRequest|null $request = null ]) : InventoriesResponse
Example:
use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\InventoryFilterType;
use RetailCrm\Api\Model\Request\Store\InventoriesRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new InventoriesRequest();
$request->filter = new InventoryFilterType();
$request->filter->productActive = NumericBoolean::TRUE;
$request->filter->sites = ['moysklad', 'aliexpress'];
try {
$response = $client->store->inventories($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Offers: ' . print_r($response->offers, true);
Parameters
- $request : InventoriesRequest|null = null
Tags
Return values
InventoriesResponseinventoriesUpload()
Makes POST "/api/v5/store/inventories/upload" request.
public
inventoriesUpload(InventoriesUploadRequest $request) : InventoriesUploadResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Store\Inventory;
use RetailCrm\Api\Model\Entity\Store\Offer;
use RetailCrm\Api\Model\Request\Store\InventoriesUploadRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$offer = new Offer();
$offer->xmlId = '1';
$offer->stores = [new Inventory('main12', 15, 15)];
$request = new InventoriesUploadRequest();
$request->offers = [$offer];
$request->site = 'aliexpress';
try {
$response = $client->store->inventoriesUpload($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Processed offers: ' . $response->processedOffersCount;
Parameters
- $request : InventoriesUploadRequest
Tags
Return values
InventoriesUploadResponseoffers()
Makes GET "/api/v5/store/offers" request.
public
offers([OffersRequest|null $request = null ]) : OffersResponse
Example:
use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\OfferFilterType;
use RetailCrm\Api\Model\Request\Store\OffersRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new OffersRequest();
$request->filter = new OfferFilterType();
$request->filter->active = NumericBoolean::TRUE;
$request->filter->name = 'Test Offer';
try {
$response = $client->store->offers($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Offers: ' . print_r($response->offers, true);
Parameters
- $request : OffersRequest|null = null
Tags
Return values
OffersResponsepricesUpload()
Makes POST "/api/v5/store/prices/upload" request.
public
pricesUpload(PricesUploadRequest $request) : PricesUploadResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Store\PriceUploadInput;
use RetailCrm\Api\Model\Entity\Store\PriceUploadPricesInput;
use RetailCrm\Api\Model\Request\Store\PricesUploadRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$price = new PriceUploadInput();
$price->site = 'aliexpress';
$price->xmlId = '1';
$price->prices = [new PriceUploadPricesInput('base', 100)];
$request = new PricesUploadRequest([$price]);
try {
$response = $client->store->pricesUpload($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
printf(
'Processed offers: %d, not found offers: %s',
$response->processedOffersCount,
print_r($response->notFoundOffers, true)
);
Parameters
- $request : PricesUploadRequest
Tags
Return values
PricesUploadResponseproductBatchEdit()
Makes POST "/api/v5/store/store/products/batch/edit" request.
public
productBatchEdit(ProductBatchEditRequest $request) : ProductBatchEditResponse
Example:
use RetailCrm\Api\Model\Entity\Store\ProductEditGroupInput;
use RetailCrm\Api\Model\Entity\Store\ProductEditInput;
use RetailCrm\Api\Model\Request\Store\ProductBatchEditRequest;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$productInput = new ProductEditInput();
$productInput->name = 'testName';
$productInput->description = 'testDescription';
$productInput->active = true;
$productInput->id = 10;
$productInput->url = 'testUrl';
$productInput->article = 'testArticle';
$productInput->catalogId = 10;
$productInput->externalId = 'testExternalId';
$productInput->manufacturer = 'testManufacturer';
$productInput->markable = true;
$productInput->novelty = true;
$productInput->popular = true;
$productInput->recommended = true;
$productInput->site = 'testSite';
$productInput->stock = true;
$productEditGroupInput = new ProductEditGroupInput();
$productEditGroupInput->externalId = 'testExternalId';
$productEditGroupInput->id = 10;
$productInput->groups[] = $productEditGroupInput;
try {
$response = $client->store->productBatchEdit(new ProductBatchEditRequest([$productInput]));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Processed product count: ' . $response->processedProductsCount;
Parameters
- $request : ProductBatchEditRequest
Tags
Return values
ProductBatchEditResponseproductGroups()
Makes GET "/api/v5/store/product-groups" request.
public
productGroups([ProductGroupsRequest|null $request = null ]) : ProductGroupsResponse
Example:
use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\ProductGroupFilterType;
use RetailCrm\Api\Model\Request\Store\ProductGroupsRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ProductGroupsRequest();
$request->filter = new ProductGroupFilterType();
$request->filter->sites = ['moysklad', 'aliexpress'];
$request->filter->active = NumericBoolean::TRUE;
try {
$response = $client->store->productGroups($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Product groups: ' . print_r($response->productGroup, true);
Parameters
- $request : ProductGroupsRequest|null = null
Tags
Return values
ProductGroupsResponseproductGroupsCreate()
Makes POST "/api/v5/store/product-groups/create" request.
public
productGroupsCreate(ProductGroupsCreateRequest $request) : IdResponse
Example:
use RetailCrm\Api\Model\Entity\Store\SerializedProductGroup;
use RetailCrm\Api\Model\Request\Store\ProductGroupsCreateRequest;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$productGroup = new SerializedProductGroup();
$productGroup->parentId = 100;
$productGroup->name = 'TestGroup';
$productGroup->description = 'Test group of products';
$productGroup->externalId = 'xxx-001';
$productGroup->active = true;
$productGroup->parentExternalId = 'xxx-000';
$productGroup->site = 'test_site';
try {
$response = $client->store->productGroupsCreate(new ProductGroupsCreateRequest($productGroup));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Product group create result: ' . $response->success;
echo 'Product group id: ' . $response->id;
Parameters
- $request : ProductGroupsCreateRequest
Tags
Return values
IdResponseproductGroupsEdit()
Makes POST "/api/v5/store/product-groups/{externalId}/edit" request.
public
productGroupsEdit(string|int $identifier, ProductGroupsEditRequest $request) : IdResponse
Example:
use RetailCrm\Api\Model\Entity\Store\SerializedProductGroup;
use RetailCrm\Api\Model\Request\Store\ProductGroupsEditRequest;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$productGroup = new SerializedProductGroup();
$productGroup->name = 'TestGroup';
$productGroup->description = 'Test group of products';
$productGroup->externalId = 'xxx-001';
$productGroup->active = true;
try {
$response = $client->store->productGroupsEdit(
111,
new ProductGroupsEditRequest($productGroup, 'externalId', 'test_site')
);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Product group create result: ' . $response->success;
echo 'Product group id: ' . $response->id;
Parameters
- $identifier : string|int
- $request : ProductGroupsEditRequest
Tags
Return values
IdResponseproducts()
Makes GET "/api/v5/store/products" request.
public
products([ProductsRequest|null $request = null ]) : ProductsResponse
Example:
use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\ProductFilterType;
use RetailCrm\Api\Model\Request\Store\ProductsRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ProductsRequest();
$request->filter = new ProductFilterType();
$request->filter->active = NumericBoolean::TRUE;
$request->filter->priceType = 'base';
$request->filter->maxPrice = '10000';
$request->filter->name = 'Test Product';
try {
$response = $client->store->products($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Products: ' . print_r($response->products, true);
Parameters
- $request : ProductsRequest|null = null
Tags
Return values
ProductsResponseproductsBatchCreate()
Makes POST "/api/v5/store/products/batch/create" request.
public
productsBatchCreate(ProductsBatchCreateRequest $request) : ProductsBatchCreateResponse
Example:
use RetailCrm\Api\Model\Entity\Store\ProductEditGroupInput;
use RetailCrm\Api\Model\Entity\Store\ProductCreateInput;
use RetailCrm\Api\Model\Request\Store\ProductsBatchCreateRequest;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Enum\Product\ProductType;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$productInput = new ProductCreateInput();
$productInput->name = 'testName';
$productInput->description = 'testDescription';
$productInput->active = true;
$productInput->url = 'testUrl';
$productInput->article = 'testArticle';
$productInput->catalogId = 10;
$productInput->externalId = 'testExternalId';
$productInput->manufacturer = 'testManufacturer';
$productInput->markable = true;
$productInput->novelty = true;
$productInput->popular = true;
$productInput->recommended = true;
$productInput->stock = true;
$productInput->type = ProductType::PRODUCT;
$productEditGroupInput = new ProductEditGroupInput();
$productEditGroupInput->externalId = 'testExternalId';
$productEditGroupInput->id = 10;
$productInput->groups[] = $productEditGroupInput;
try {
$response = $client->store->productsBatchCreate(new ProductsBatchCreateRequest([$productInput]));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Processed product count: ' . $response->processedProductsCount;
Parameters
- $request : ProductsBatchCreateRequest
Tags
Return values
ProductsBatchCreateResponseproductsProperties()
Makes GET "/api/v5/store/products/properties" request.
public
productsProperties([ProductPropertiesRequest|null $request = null ]) : ProductPropertiesResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\ProductPropertiesFilterType;
use RetailCrm\Api\Model\Request\Store\ProductPropertiesRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ProductPropertiesRequest();
$request->filter = new ProductPropertiesFilterType();
$request->filter->sites = ['moysklad', 'aliexpress'];
try {
$response = $client->store->productsProperties($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Product properties: ' . print_r($response->properties, true);
Parameters
- $request : ProductPropertiesRequest|null = null
Tags
Return values
ProductPropertiesResponseproductsPropertyValues()
Makes GET "/api/v5/store/products/properties/values" request.
public
productsPropertyValues([ProductPropertyValuesRequest|null $request = null ]) : ProductPropertyValuesResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Store\ProductPropertiesFilterType;
use RetailCrm\Api\Model\Request\Store\ProductPropertiesRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ProductPropertyValuesRequest();
$request->filter = new ProductPropertyValuesFilterType();
$request->filter->propertyCode = 'property_code';
try {
$response = $client->store->productsPropertyValues($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Product property values: ' . print_r($response->productPropertyValues, true);
Parameters
- $request : ProductPropertyValuesRequest|null = null