1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
catalog.php
См. документацию.
1<?php
2
3namespace Bitrix\Seo\BusinessSuite;
4
5use Bitrix\Main\Application;
6use Bitrix\Main\Error;
7use Bitrix\Main\Text\Encoding;
8use Bitrix\Main\Web\Json;
9use Bitrix\Seo\BusinessSuite\Configuration\Facebook\Installs;
10use Bitrix\Seo\BusinessSuite\Configuration\Facebook\Setup;
11use Bitrix\Seo\Retargeting\Response;
12
13abstract class Catalog extends AbstractBase
14{
15 private function getSetup(): Setup
16 {
17 static $setup = null;
18
19 if ($setup === null)
20 {
21 $setup = Setup::load();
22 }
23
24 return $setup;
25 }
26
27 private function getBusinessId(): ?string
28 {
29 $setup = $this->getSetup();
30
31 return $setup->get($setup::BUSINESS_ID);
32 }
33
34 private function getInstalls(): Installs
35 {
36 static $installs = null;
37
38 if ($installs === null)
39 {
40 $installs = Installs::load();
41 }
42
43 return $installs;
44 }
45
46 private function getCatalogId(): ?string
47 {
48 return $this->getInstalls()->getCatalog();
49 }
50
51 private function createResponseWithError(string $error): Response
52 {
53 return Response::create(self::TYPE_CODE)->addError(new Error($error));
54 }
55
56 private function sendRequest(string $name, array $data = []): Response
57 {
58 $businessId = $this->getBusinessId();
59 if ($businessId === null)
60 {
61 return $this->createResponseWithError('Empty business id.');
62 }
63
64 return
65 $this
66 ->getRequest()
67 ->send([
68 'methodName' => $this->getMethodName($name),
69 'parameters' => array_merge(
70 $data,
71 [
72 'fbe_external_business_id' => $businessId,
73 ]
74 ),
75 ])
76 ;
77 }
78
79 public function batchCatalogProducts(array $productData): Response
80 {
81 if (empty($productData))
82 {
83 return $this->createResponseWithError('Empty product data.');
84 }
85
86 return $this->sendRequest('catalog.products.batch', [
87 'allow_upsert' => true,
88 'requests' => $productData,
89 ]);
90 }
91
92 public function checkBatchRequestStatus(string $handle): Response
93 {
94 if ($handle === '')
95 {
96 return $this->createResponseWithError('Empty handle data.');
97 }
98
99 return $this->sendRequest('catalog.products.check.batch.status', [
100 'catalog_id' => $this->getCatalogId(),
101 'load_ids_of_invalid_requests' => true,
102 'handle' => $handle,
103 ]);
104 }
105
106 public function getProductsInfo(array $retailerIds): Response
107 {
108 if (empty($retailerIds))
109 {
110 return $this->createResponseWithError('Empty retailer ids.');
111 }
112
113 return $this->sendRequest('catalog.products.get.info', [
114 'catalog_id' => $this->getCatalogId(),
115 'filter' => Json::encode([
116 'retailer_id' => [
117 'is_any' => $retailerIds,
118 ]
119 ]),
120 'fields' => 'id, retailer_id, review_status, review_rejection_reasons',
121 ]);
122 }
123}
Определения error.php:15
Определения response.php:5
getMethodName(string $name)
Определения abstractbase.php:20
getProductsInfo(array $retailerIds)
Определения catalog.php:106
checkBatchRequestStatus(string $handle)
Определения catalog.php:92
batchCatalogProducts(array $productData)
Определения catalog.php:79
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$handle
Определения include.php:55
$name
Определения menu_edit.php:35
Определения catalog.php:3
$error
Определения subscription_card_product.php:20