Creates the subscription entries for the ordered products with interval attributes

@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
767761
protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'subscription' );

		foreach( $basket->getProducts() as $orderProduct )
		{
			if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null )
			{
				$item = $manager->createItem()->setInterval( $interval )
					->setOrderProductId( $orderProduct->getId() )
					->setOrderBaseId( $basket->getId() );

				if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null
					|| ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null
					|| ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null
				) {
					$item = $item->setDateEnd( $end );
				}

				$manager->saveItem( $item, false );
			}
		}
	}
912532
public function set( \Aimeos\MShop\Common\Item\Iface $item )
	{
		$code = $item->getCode();

		if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) {
			$this->attributes[$code] = [];
		}

		$this->attributes[$code][$item->getType()] = $item;
	}
1003743
public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' );
		$map = $this->getMappedChunk( $data, $this->getMapping() );

		foreach( $map as $list )
		{
			if( trim( $list['coupon.code.code'] ) == '' ) {
				continue;
			}

			$item = $manager->saveItem( $item->fromArray( $list ) );
		}

		return $this->getObject()->process( $item, $data );
	}
857039
protected static function addProcess( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_process'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_process'] ) )
		) {
			return $fcn( $context );
		}

		$process = new \Aimeos\MW\Process\Pcntl( \Aimeos\Aimeos\Base::getExtConfig( 'pcntlMax', 4 ) );

		// Reset before child processes are spawned to avoid lost DB connections afterwards (TYPO3 9.4 and above)
		if( $process->isAvailable() === false
			|| version_compare( TYPO3_version, '9.4' ) < 0
			|| method_exists( '\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections' ) === false
		) {
			$process = new \Aimeos\MW\Process\None();
		}

		return $context->setProcess( $process );
	}
443627
public function setBasket(Basket $basket = null)
    {
        if ($this->basket) {
            $this->basket->setOrder(null);
        }

        $this->basket = $basket;

        if ($basket) {
            $basket->setOrder($this);
        }

        return $this;
    }
717780
protected function fromArray( \Aimeos\MShop\Supplier\Item\Iface $item, array $data )
	{
		$context = $this->getContext();

		$mediaManager = \Aimeos\MShop::create( $context, 'media' );
		$listManager = \Aimeos\MShop::create( $context, 'supplier/lists' );
		$cntl = \Aimeos\Controller\Common\Media\Factory::create( $context );

		$listItems = $item->getListItems( 'media', null, null, false );
		$files = (array) $this->getView()->request()->getUploadedFiles();

		foreach( $data as $idx => $entry )
		{
			if( ( $listItem = $item->getListItem( 'media', $entry['supplier.lists.type'], $entry['media.id'], false ) ) === null ) {
				$listItem = $listManager->createItem();
			}

			if( ( $refItem = $listItem->getRefItem() ) === null ) {
				$refItem = $mediaManager->createItem();
			}

			$refItem->fromArray( $entry, true );

			if( ( $file = $this->getValue( $files, 'media/' . $idx . '/file' ) ) !== null && $file->getError() !== UPLOAD_ERR_NO_FILE )
			{
				$refItem->getId() ?: $refItem->setUrl( '' )->setPreview( '' ); // keep copied media
				$cntl->add( $refItem, $file );
			}

			$conf = [];

			foreach( (array) $this->getValue( $entry, 'config/key' ) as $num => $key )
			{
				if( trim( $key ) !== '' && ( $val = $this->getValue( $entry, 'config/val/' . $num ) ) !== null ) {
					$conf[$key] = trim( $val );
				}
			}

			$listItem->fromArray( $entry, true );
			$listItem->setPosition( $idx );
			$listItem->setConfig( $conf );

			$item->addListItem( 'media', $listItem, $refItem );

			unset( $listItems[$listItem->getId()] );
		}

		return $this->deleteMediaItems( $item, $listItems );
	}
452349
protected function addDatabaseManager( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$dbm = new \Aimeos\MW\DB\Manager\DBAL( $context->getConfig() );

		return $context->setDatabaseManager( $dbm );
	}
1166899
public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Iface $order )
	{
	}
586246
public function process(Basket $basket)
    {
        $meta     = $this->meta($basket);
        $products = $this->products($basket);

        return new Order($meta, $products);
    }
1049256
public function set( \Aimeos\MShop\Common\Item\Iface $item )
	{
		$this->prodmap[$item->getCode()] = $item->getId();
	}
687937
protected function addMailer( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$container = $this->container;
		$mail = new \Aimeos\MW\Mail\Swift( function() use ( $container) { return $container->get( 'mailer' ); } );

		return $context->setMail( $mail );
	}
527964
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'stock.productcode', $item->getCode() ) );
		$stockItems = $manager->searchitems( $search );

		$list = (array) $this->getValue( $data, 'stock.id', [] );

		foreach( $list as $idx => $id )
		{
			$type = $this->getValue( $data, 'stock.type/' . $idx );

			if( isset( $stockItems[$id] ) && $stockItems[$id]->getType() == $type )
			{
				$stockItem = $stockItems[$id];
				unset( $stockItems[$id] );
			}
			else
			{
				$stockItem = $manager->createItem()->setType( $type );
			}

			$stockItem->setProductCode( $item->getCode() );
			$stockItem->setStocklevel( $this->getValue( $data, 'stock.stocklevel/' . $idx ) );
			$stockItem->setDateBack( $this->getValue( $data, 'stock.dateback/' . $idx ) );

			$manager->saveItem( $stockItem, false );
		}

		$manager->deleteItems( array_keys( $stockItems ) );
	}
1239184
protected function createNodeArray( \Aimeos\MShop\Locale\Item\Site\Iface $item )
	{
		$result = $item->toArray( true );

		if( method_exists( $item, 'getChildren' ) )
		{
			foreach( $item->getChildren() as $child ) {
				$result['children'][] = $this->createNodeArray( $child );
			}
		}

		return (object) $result;
	}
337072
private function addProductSeven(Basket $basket)
    {
        $seven = $this->products->seven();

        $basket->add($seven->sku, $seven->name, $seven->price, function ($product) use ($seven) {
            $product->quantity($seven->quantity);
            $product->discount($seven->discount);
            $product->delivery($seven->delivery);
        });

        return $basket;
    }
68558
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$context = $this->getContext();
		$manager = \Aimeos\MShop::create( $context, 'product' );
		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );

		$prodItem = $manager->createItem()->setType( 'default' );
		$listItem = $listManager->createItem()->setType( 'default' );
		$articles = $item->getRefItems( 'product', null, 'default', false );
		$listItems = $item->getListItems( 'product', 'default', null, false );

		foreach( $data as $idx => $entry )
		{
			if( ( $litem = $item->getListItem( 'product', 'default', $entry['product.id'], false ) ) === null ) {
				$litem = clone $listItem;
			}

			if( isset( $articles[$litem->getRefId()] ) ) {
				$refItem = $articles[$litem->getRefId()];
			} else {
				$refItem = clone $prodItem;
			}

			$litem->fromArray( $entry, true );
			$litem->setPosition( $idx );

			$refItem->fromArray( $entry, true );

			if( isset( $entry['attr'] ) ) {
				$refItem = $this->fromArrayAttributes( $refItem, $entry['attr'] );
			}

			$item->addListItem( 'product', $litem, $refItem );
			unset( $listItems[$litem->getId()] );
		}

		return $item->deleteListItems( $listItems );
	}
576530
protected static function addGroups( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_groups'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_groups'] ) )
		) {
			return $fcn( $context );
		}

		if( TYPO3_MODE === 'FE' && $GLOBALS['TSFE']->loginUser == 1 )
		{
			$ids = GeneralUtility::trimExplode( ',', $GLOBALS['TSFE']->fe_user->user['usergroup'] );
			$context->setGroupIds( $ids );
		}
		elseif( TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->userGroups )
		{
			$ids = array_keys( $GLOBALS['BE_USER']->userGroups );
			$context->setGroupIds( $ids );
		}

		return $context;
	}
408956
protected function addCache( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );

		return $context->setCache( $cache );
	}