15 private function getSetup():
Setup
21 $setup = Setup::load();
27 private function getBusinessId(): ?
string
29 $setup = $this->getSetup();
31 return $setup->get($setup::BUSINESS_ID);
34 private function getInstalls():
Installs
36 static $installs =
null;
38 if ($installs ===
null)
40 $installs = Installs::load();
46 private function getCatalogId(): ?
string
48 return $this->getInstalls()->getCatalog();
51 private function createResponseWithError(
string $error):
Response
53 return Response::create(self::TYPE_CODE)->addError(
new Error($error));
56 private function sendRequest(
string $name, array $data = []):
Response
58 $businessId = $this->getBusinessId();
59 if ($businessId ===
null)
61 return $this->createResponseWithError(
'Empty business id.');
69 'parameters' => array_merge(
72 'fbe_external_business_id' => $businessId,
81 if (empty($productData))
83 return $this->createResponseWithError(
'Empty product data.');
88 $productData = (array)Encoding::convertEncoding($productData,
'Windows-1251',
'UTF-8');
91 return $this->sendRequest(
'catalog.products.batch', [
92 'allow_upsert' =>
true,
93 'requests' => $productData,
101 return $this->createResponseWithError(
'Empty handle data.');
104 return $this->sendRequest(
'catalog.products.check.batch.status', [
105 'catalog_id' => $this->getCatalogId(),
106 'load_ids_of_invalid_requests' =>
true,
113 if (empty($retailerIds))
115 return $this->createResponseWithError(
'Empty retailer ids.');
118 return $this->sendRequest(
'catalog.products.get.info', [
119 'catalog_id' => $this->getCatalogId(),
120 'filter' => Json::encode([
122 'is_any' => $retailerIds,
125 'fields' =>
'id, retailer_id, review_status, review_rejection_reasons',