Returns the backend configuration attributes of the provider and decorators

@param \Aimeos\MShop\Service\Item\Iface $item Service item incl. provider/decorator property
@return \Aimeos\MW\Common\Critera\Attribute\Iface[] List of configuration attributes
330248
public function getConfigAttributes( \Aimeos\MShop\Service\Item\Iface $item )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'service' );

		try {
			return $manager->getProvider( $item, $item->getType() )->getConfigBE();
		} catch( \Aimeos\MShop\Exception $e ) {
			return [];
		}
	}
763029
protected function getItemBase( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $row )
	{
		foreach( $row as $idx => $value ) {
			$row[$idx] = trim( $value );
		}

		$count = ( isset( $row[1] ) && $row[1] != '' ? $row[1] : 1 );
		$start = ( isset( $row[2] ) && $row[2] != '' ? $row[2] : null );
		$end = ( isset( $row[3] ) && $row[3] != '' ? $row[3] : null );

		$item->setId( null );
		$item->setCode( $row[0] );
		$item->setCount( $count );
		$item->setDateStart( $start );
		$item->setDateEnd( $end );

		return $item;
	}
501445
protected function toArray( \Aimeos\MShop\Catalog\Item\Iface $item, $copy = false )
	{
		$data = $item->toArray( true );
		$data['config'] = [];

		if( $copy === true )
		{
			$data['catalog.id'] = '';
			$data['catalog.siteid'] = $item->getSiteId();
			$data['catalog.code'] = $data['catalog.code'] . '_copy';
		}

		foreach( $item->getConfig() as $key => $value )
		{
			$data['config']['key'][] = $key;
			$data['config']['val'][] = $value;
		}

		return $data;
	}
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;
	}
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 );
	}
1049256
public function set( \Aimeos\MShop\Common\Item\Iface $item )
	{
		$this->prodmap[$item->getCode()] = $item->getId();
	}
1013376
public function get( $item )
    {
        return isset( $this->config[$item] ) ? $this->config[$item] : null;
    }
878573
protected function fromArray( \Aimeos\MShop\Customer\Item\Iface $item, array $data )
	{
		$context = $this->getContext();
		$listIds = $this->getValue( $data, 'customer.lists.id', [] );

		$listManager = \Aimeos\MShop::create( $context, 'customer/lists' );

		$search = $listManager->createSearch()->setSlice( 0, count( $listIds ) );
		$search->setConditions( $search->compare( '==', 'customer.lists.id', $listIds ) );

		$listItems = $listManager->searchItems( $search );


		foreach( (array) $listIds as $idx => $listid )
		{
			if( isset( $listItems[$listid] ) ) {
				$litem = $listItems[$listid];
			} else {
				$litem = $listManager->createItem();
			}

			$litem->setParentId( $item->getId() );
			$litem->setDomain( 'product' );

			if( isset( $data['customer.lists.refid'][$idx] ) ) {
				$litem->setRefId( $this->getValue( $data, 'customer.lists.refid/' . $idx ) );
			}

			if( isset( $data['customer.lists.status'][$idx] ) ) {
				$litem->setStatus( $this->getValue( $data, 'customer.lists.status/' . $idx ) );
			}

			if( isset( $data['customer.lists.type'][$idx] ) ) {
				$litem->setType( $this->getValue( $data, 'customer.lists.type/' . $idx ) );
			}

			if( isset( $data['customer.lists.position'][$idx] ) ) {
				$litem->setPosition( $this->getValue( $data, 'customer.lists.position/' . $idx ) );
			}

			if( isset( $data['customer.lists.datestart'][$idx] ) ) {
				$litem->setDateStart( $this->getValue( $data, 'customer.lists.datestart/' . $idx ) );
			}

			if( isset( $data['customer.lists.dateend'][$idx] ) ) {
				$litem->setDateEnd( $this->getValue( $data, 'customer.lists.dateend/' . $idx ) );
			}

			if( isset( $data['customer.lists.config'][$idx] )
				&& ( $conf = json_decode( $this->getValue( $data, 'customer.lists.config/' . $idx ), true ) ) !== null
			) {
				$litem->setConfig( $conf );
			}

			if( $litem->getId() === null && isset( $data['config'][$idx]['key'] ) )
			{
				$conf = [];

				foreach( (array) $data['config'][$idx]['key'] as $pos => $key )
				{
					if( trim( $key ) !== '' && isset( $data['config'][$idx]['val'][$pos] ) ) {
						$conf[$key] = $data['config'][$idx]['val'][$pos];
					}
				}

				$litem->setConfig( $conf );
			}

			$listManager->saveItem( $litem, false );
		}
	}
362516
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$context = $this->getContext();
		$fs = $context->getFilesystemManager()->get( 'fs-secure' );

		$attrManager = \Aimeos\MShop::create( $context, 'attribute' );
		$typeManager = \Aimeos\MShop::create( $context, 'attribute/type' );
		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );

		$attrItem = $attrManager->createItem()->setType( 'download' );
		$listItem = $listManager->createItem()->setType( 'hidden' );
		$listItems = $item->getListItems( 'attribute', 'hidden', 'download', false );

		if( $this->getValue( $data, 'attribute.label' ) != '' )
		{
			$listId = $this->getValue( $data, 'product.lists.id' );

			if( isset( $listItems[$listId] ) ) {
				$litem = $listItems[$listId]; unset( $listItems[$listId] );
			} else {
				$litem = clone $listItem;
			}

			if( ( $refItem = $litem->getRefItem() ) === null ) {
				$refItem = clone $attrItem;
			}

			$litem->fromArray( $data, true );
			$refItem->fromArray( $data, true );

			if( ( $file = $this->getValue( (array) $this->getView()->request()->getUploadedFiles(), 'download/file' ) ) !== null
				&& $file->getError() === UPLOAD_ERR_OK
			) {
				$path = ( $this->getValue( $data, 'overwrite' ) == 1 ? $refItem->getCode() : null );
				$refItem->setCode( $this->storeFile( $file, $path ) );
			}

			$item->addListItem( 'attribute', $litem, $refItem );
		}

		foreach( $listItems as $listItem )
		{
			$refItem = $listItem->getRefItem();

			if( $refItem !== null && ( $path = $refItem->getCode() ) != '' && $fs->has( $path ) ) {
				$fs->rm( $path );
			}

			$item->deleteListItem( 'attribute', $listItem, $refItem );
		}
	}
1302419
public function getGroups( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$list = array();
		$manager = \Aimeos\MShop::create( $context, 'customer/group' );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'customer.group.id', $context->getGroupIds() ) );

		foreach( $manager->searchItems( $search ) as $item ) {
			$list[] = $item->getCode();
		}

		return $list;
	}
570698
public function get( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( $this->locale === null )
		{
			$site = Input::get( 'site', 'default' );
			$currency = Input::get( 'currency', '' );
			$lang = Input::get( 'locale', '' );

			if( Route::current() )
			{
				$site =  Route::input( 'site', $site );
				$currency = Route::input( 'currency', $currency );
				$lang = Route::input( 'locale', $lang );
			}

			$localeManager = \Aimeos\MShop::create( $context, 'locale' );
			$disableSites = $this->config->get( 'shop.disableSites', true );

			try {
				$this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
			} catch( \Aimeos\MShop\Locale\Exception $e ) {
				$this->locale = $localeManager->bootstrap( 'default', $lang, $currency, $disableSites );
			}
		}

		return $this->locale;
	}
1250021
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );
		$typeManager = \Aimeos\MShop::create( $this->getContext(), 'product/property/type' );

		foreach( $data as $type => $value )
		{
			$propItems = $item->getPropertyItems( $type, false );

			if( ( $value = trim( $value ) ) != '' )
			{
				if( ( $propItem = reset( $propItems ) ) === false ) {
					$propItem = $manager->createItem()->setType( $type );
				}

				$propItem->setLanguageId( null );
				$propItem->setValue( $value );

				$item->addPropertyItem( $propItem );
			}
			else
			{
				$item->deletePropertyItems( $propItems );
			}
		}
	}
733047
public function matchItem(ItemInterface $item)
    {
        if (null === $this->getRequest()) {
            return null;
        }

        $route = $this->getRequest()->attributes->get('_route');
        $routeParameters = $this->getRequest()->attributes->get('_route_params');

        if (null === $route) {
            return null;
        }


        $routes = $item->getExtra('routes', []);
        if (false === is_array($routes)) {
            return null;
        }

        foreach ($routes as $testedRoute) {
            /* Route matching? */
            if ($route !== $testedRoute['route']) {
                continue;
            }

            /* No Parameters? */
            if (false === is_array($routeParameters) || 0 === count($routeParameters)) {
                return true;
            }

            /* Parameters only in current route? */
            if (false === isset($testedRoute['parameters']) || false === is_array($testedRoute['parameters'])) {
                continue;
            }

            /* Assume match, until different parameters are found */
            $matching = true;

            foreach ($routeParameters as $index => $value) {
                /* Ignore underscored parameters */
                if ('_' === substr($index, 0, 1)) {
                    continue;
                }

                /* Parameter not found */
                if (false === isset($testedRoute['parameters'][$index])) {
                    $matching = false;

                    break;
                }

                /* Parameter not matching */
                if ($testedRoute['parameters'][$index] !== $value && ((0 < $testedRoute['parameters'][$index]) || false === is_numeric($value))) {
                    $matching = false;

                    break;
                }
            }

            if (true === $matching) {
                return true;
            }

        }

        return null;
    }
1035428
protected function getNodeList( \Aimeos\MShop\Catalog\Item\Iface $node )
	{
		$nodes = array( $node );

		foreach( $node->getChildren() as $child ) {
			$nodes = array_merge( $nodes, $this->getNodeList( $child ) );
		}

		return $nodes;
	}
1088416
protected function getProductItems( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds )
	{
		$productManager = \Aimeos\MShop::create( $context, 'product' );

		$search = $productManager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'product.id', $prodIds ),
			$search->getConditions(),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSlice( 0, count( $prodIds ) );

		return $productManager->searchItems( $search, array( 'text', 'price', 'media' ) );
	}
260388
protected static function addUser( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_user'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_user'] ) )
		) {
			return $fcn( $context );
		}

		if( TYPO3_MODE === 'FE' && $GLOBALS['TSFE']->loginUser == 1 )
		{
			$context->setUserId( $GLOBALS['TSFE']->fe_user->user[$GLOBALS['TSFE']->fe_user->userid_column] );
			$context->setEditor( $GLOBALS['TSFE']->fe_user->user['username'] );
		}
		elseif( TYPO3_MODE === 'BE' && isset( $GLOBALS['BE_USER']->user['username'] ) )
		{
			$context->setEditor( $GLOBALS['BE_USER']->user['username'] );
		}
		else
		{
			$context->setEditor( GeneralUtility::getIndpEnv( 'REMOTE_ADDR' ) );
		}

		return $context;
	}
204618
public function normalizeStateOrCityData($item)
    {
        $fields = [
            ['cca2', 'iso_a2'],
            ['name.common', 'admin'],
            ['name.official', 'admin'],
            ['adm0_a3', 'adm0_a3'],
        ];

        list(, $countryCode) = $this->findByFields($this->_countries, $item, $fields, 'cca3');

        if (is_null($countryCode)) {
            $countryCode = $this->helper->caseForKey($item['name']);
        }

        $item['iso_a3'] = ! isset($item['iso_a3'])
            ? $countryCode
            : $item['iso_a3'];

        $item['cca3'] = $item['iso_a3'];

        $item['cca2'] = $item['iso_a2'];

        return $item;
    }