1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ShopManager.php
См. документацию.
1<?php
2
4
10
11final class ShopManager
12{
13 private bool $isLandingIncluded;
14 private const EXCLUDED_SITES = [
15 'store-chats-dark',
16 'store-chats-light',
17 'store-chats',
18 ];
19
20 public function __construct()
21 {
22 $this->isLandingIncluded = Loader::includeModule('landing');
23 }
24
25 public function areTherePublishedShops(): bool
26 {
27 return !empty($this->getPublishedShopsIds());
28 }
29
30 private function getPublishedShopsIds(): array
31 {
32 if (!$this->isLandingIncluded)
33 {
34 return [];
35 }
36
37 $result = [];
38
39 $activeShopsList = SiteTable::getList([
40 'select' => [
41 'ID',
42 'TYPE',
43 'ACTIVE',
44 'TPL_CODE',
45 ],
46 'filter' => [
47 '=TYPE' => 'STORE',
48 '=ACTIVE' => 'Y',
49 ],
50 ]);
51
52 while ($site = $activeShopsList->fetch())
53 {
54 if (in_array($site['TPL_CODE'], self::EXCLUDED_SITES, true))
55 {
56 continue;
57 }
58
59 $result[] = (int)$site['ID'];
60 }
61
62 return $result;
63 }
64
65 public function unpublishShops(): Result
66 {
67 $result = new Result();
68
69 if (!$this->isLandingIncluded)
70 {
71 $result->addError(new Error('The landing module is not installed'));
72
73 return $result;
74 }
75
76 $publishedShopsIds = $this->getPublishedShopsIds();
77 foreach ($publishedShopsIds as $publishedShopsId)
78 {
79 $siteResult = Site::unpublic((int)$publishedShopsId);
80 if (!$siteResult->isSuccess())
81 {
82 $result->addErrors($siteResult->getErrors());
83 }
84 }
85
86 return $result;
87 }
88}
Определения error.php:15
Определения loader.php:13
static getList(array $parameters=array())
Определения datamanager.php:431
Определения site.php:31
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
Определения cookies.php:2
$site
Определения yandex_run.php:614