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/yandex.market/lib/migration/v283/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/yandex.market/lib/migration/v283/moveshopskutoid.php
<?php
namespace Yandex\Market\Migration\V283;

use Yandex\Market;

class MoveShopSkuToId
{
	public static function apply()
	{
		$shopSkuTags = self::shopSkuTags();
		$offerTags = self::offerTags(array_column($shopSkuTags, 'IBLOCK_LINK_ID'));
		$idAttributes = self::idAttributes(array_column($offerTags, 'ID'));

		foreach ($shopSkuTags as $shopSkuTag)
		{
			$iblockLinkId = (int)$shopSkuTag['IBLOCK_LINK_ID'];

			if (!isset($offerTags[$iblockLinkId])) { continue; }

			$offerTag = $offerTags[$iblockLinkId];

			if (isset($idAttributes[$offerTag['ID']]))
			{
				Market\Export\ParamValue\Table::delete($idAttributes[$offerTag['ID']]['ID']);
			}

			Market\Export\ParamValue\Table::update($shopSkuTag['ID'], [
				'PARAM_ID' => $offerTag['ID'],
				'XML_TYPE' => Market\Export\ParamValue\Table::XML_TYPE_ATTRIBUTE,
				'XML_ATTRIBUTE_NAME' => 'id',
			]);

			Market\Export\Param\Table::delete($shopSkuTag['PARAM_ID']);
		}
	}

	private static function shopSkuTags()
	{
		$query = Market\Export\ParamValue\Table::getList([
			'filter' => [ '=PARAM.XML_TAG' => 'shop-sku' ],
			'select' => [
				'ID',
				'PARAM_ID',
				'IBLOCK_LINK_ID' => 'PARAM.IBLOCK_LINK_ID',
			],
		]);

		return $query->fetchAll();
	}

	private static function offerTags(array $iblockLinkIds)
	{
		if (empty($iblockLinkIds)) { return []; }

		$query = Market\Export\Param\Table::getList([
			'filter' => [
				'=IBLOCK_LINK_ID' => $iblockLinkIds,
				'=XML_TAG' => 'offer',
			],
			'select' => [ 'IBLOCK_LINK_ID', 'ID' ],
		]);

		return Market\Utils\ArrayHelper::columnToKey($query->fetchAll(), 'IBLOCK_LINK_ID');
	}

	private static function idAttributes(array $paramIds)
	{
		if (empty($paramIds)) { return []; }

		$query = Market\Export\ParamValue\Table::getList([
			'filter' => [
				'=PARAM_ID' => $paramIds,
				'=XML_TYPE' => Market\Export\ParamValue\Table::XML_TYPE_ATTRIBUTE,
				'=XML_ATTRIBUTE_NAME' => 'id',
			],
		]);

		return Market\Utils\ArrayHelper::columnToKey($query->fetchAll(), 'PARAM_ID');
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit