• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/v2/Integration/Landing/StoreV3Master.php
  • Класс: BitrixCatalogv2IntegrationLandingStoreV3Master
  • Вызов: StoreV3Master::deactivateUnusedStore
static function deactivateUnusedStore(): Result
{
	$result = new Result();

	if (!self::hasUnusedStores())
	{
		return $result->addError(
			new Error('There are no unused stores on the portal.')
		);
	}

	Rights::setGlobalOff();
	$deactivatedStore = null;

	foreach (self::getUnusedStoresList() as $storeId)
	{
		$result = Site::update($storeId, ['ACTIVE' => 'N']);
		if ($result->isSuccess())
		{
			$deactivatedStore = Site::getList([
				'select' => ['ID', 'TITLE'],
				'filter' => ['=ID' => $storeId],
			])
				->fetch()
			;
			if ($deactivatedStore)
			{
				$result->setData(compact('deactivatedStore'));
			}

			break;
		}
	}

	Rights::setGlobalOn();
	if (!$deactivatedStore)
	{
		$result->addError(new Error('Failed to deactivate unused stores.'));
	}

	return $result;
}