403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/catalog/lib/store/enablewizard/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/catalog/lib/store/enablewizard/conditionschecker.php
<?php

namespace Bitrix\Catalog\Store\EnableWizard;

use Bitrix\Catalog\ProductTable;
use Bitrix\Catalog\StoreDocumentTable;
use Bitrix\Catalog\v2\Integration\Landing\ShopManager;
use Bitrix\Main\Application;
use Bitrix\Main\DB\SqlExpression;
use Bitrix\Main\Type\Collection;

class ConditionsChecker
{
	public static function hasConductedDocumentsOrQuantities(): bool
	{
		return (
			self::doesProductWithQuantityExist()
			|| self::doesConductedDocumentExist()
		);
	}

	public static function areTherePublishedShops(): bool
	{
		return (new ShopManager())->areTherePublishedShops();
	}

	public static function areThereActiveProducts(): bool
	{
		$iblockIds = ProductDisabler::getIblocksForDisabling();
		Collection::normalizeArrayValuesByInt($iblockIds);
		if (empty($iblockIds))
		{
			return false;
		}

		$iblockIds = implode(', ', $iblockIds);

		return (bool)Application::getConnection()->query("
			SELECT ie.ACTIVE
			FROM b_catalog_product cp
			JOIN b_iblock_element ie on ie.ID = cp.ID
			WHERE ie.ACTIVE = 'Y'
			AND ie.IBLOCK_ID in ($iblockIds)
			LIMIT 1
		")->fetch();
	}

	public static function doesProductWithQuantityExist(): bool
	{
		$connection = Application::getConnection();

		$productTypes = new SqlExpression('(?i, ?i)', ProductTable::TYPE_PRODUCT, ProductTable::TYPE_OFFER);
		$query = $connection->query("
			select ID from b_catalog_product cp
			where TYPE in {$productTypes} and (QUANTITY != 0 or QUANTITY_RESERVED != 0)
			limit 1
		");

		if ($query->fetch())
		{
			return true;
		}

		$query = $connection->query("
			select ID from b_catalog_store_product csp
			where AMOUNT != 0 or QUANTITY_RESERVED != 0
			limit 1
		");

		if ($query->fetch())
		{
			return true;
		}

		return false;
	}

	public static function doesConductedDocumentExist(): bool
	{
		$iterator = StoreDocumentTable::getList([
			'select' => [
				'ID',
			],
			'filter' => [
				'=STATUS' => 'Y',
			],
			'limit' => 1,
		]);
		$row = $iterator->fetch();
		unset($iterator);

		return !empty($row);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit