• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/ProductGrid/StoreDataProvider.php
  • Класс: BitrixCrmMobileProductGridStoreDataProvider
  • Вызов: StoreDataProvider::getProductInitialStore
static function getProductInitialStore(int $productId): ?array
{
	$storeId = null;
	if (
		!is_null(self::$defaultStoreId)
		&& isset(self::$productToStores[$productId][self::$defaultStoreId])
		&& (float)self::$productToStores[$productId][self::$defaultStoreId]['AMOUNT'] > 0
	)
	{
		$storeId = self::$defaultStoreId;
	}
	elseif (isset(self::$productToStores[$productId]))
	{
		foreach (self::$productToStores[$productId] as $productStoreId => $productStore)
		{
			if (!isset(self::$stores[$productStoreId]))
			{
				continue;
			}

			if ((float)self::$productToStores[$productId][$productStoreId]['AMOUNT'] > 0)
			{
				$storeId = (int)$productStoreId;
				break;
			}
		}
	}

	if (is_null($storeId) && !empty(self::$stores))
	{
		$storeId = (int)key(self::$stores);
	}

	if (!$storeId)
	{
		return null;
	}

	$store = StoreTable::getById($storeId)->fetch();
	if (!$store)
	{
		return null;
	}

	return [
		'ID' => (int)$store['ID'],
		'TITLE' => (string)$store['TITLE'],
	];
}