Constructs the data array for the view from the given item

@param \Aimeos\MShop\Customer\Item\Iface $item Customer item object
@return string[] Multi-dimensional associative list of item data
194883
protected function toArray( \Aimeos\MShop\Customer\Item\Iface $item, $copy = false )
	{
		$data = $item->toArray( true );

		if( $copy === true )
		{
			$data['customer.siteid'] = $this->getContext()->getLocale()->getSiteId();
			$data['customer.email'] = '';
			$data['customer.id'] = '';
		}

		return $data;
	}
904303
protected function toArray( \Aimeos\MShop\Order\Item\Base\Iface $item, $copy = false )
	{
		$siteId = $this->getContext()->getLocale()->getSiteId();
		$data = $item->toArray( true );

		if( $item->getCustomerId() != '' )
		{
			$manager = \Aimeos\MShop::create( $this->getContext(), 'customer' );

			try {
				$data += $manager->getItem( $item->getCustomerId() )->toArray();
			} catch( \Exception $e ) {};
		}


		if( $copy === true )
		{
			$data['order.base.siteid'] = $siteId;
			$data['order.base.id'] = '';
		}

		foreach( $item->getAddresses() as $type => $addresses )
		{
			foreach( $addresses as $pos => $addrItem )
			{
				$list = $addrItem->toArray( true );

				foreach( $list as $key => $value ) {
					$data['address'][$type][$pos][$key] = $value;
				}

				if( $copy === true )
				{
					$data['address'][$type][$pos]['order.base.address.siteid'] = $siteId;
					$data['address'][$type][$pos]['order.base.address.id'] = '';
				}
			}
		}

		if( $copy !== true )
		{
			foreach( $item->getServices() as $type => $services )
			{
				foreach( $services as $serviceItem )
				{
					$serviceId = $serviceItem->getServiceId();

					foreach( $serviceItem->getAttributeItems() as $attrItem )
					{
						foreach( $attrItem->toArray( true ) as $key => $value ) {
							$data['service'][$type][$serviceId][$key][] = $value;
						}
					}
				}
			}
		}

		foreach( $item->getProducts() as $pos => $productItem ) {
			$data['product'][$pos]['order.base.product.status'] = $productItem->getStatus();
		}

		return $data;
	}
275481
public function parse(array $item): array
    {
        if (\count($item['fieldLayout']) > 1) {
            $errors = [
                'fieldLayout' => [
                    Architect::t('Field layout can only have 1 tab.')

                ]
            ];
            return [null, $errors];
        }

        $tagGroup = new TagGroup([
            'name' => $item['name'],
            'handle' => $item['handle'],
        ]);

        $fieldLayout = new FieldLayout();
        $fieldLayout->type = Tag::class;

        return [$tagGroup, null];
    }
593947
protected function toArray( \Aimeos\MShop\Common\Item\Type\Iface $item, $copy = false )
	{
		$data = $item->toArray( true );

		if( $copy === true )
		{
			$data['price.lists.type.code'] = $data['price.lists.type.code'] . '_copy';
			$data['price.lists.type.id'] = '';
		}

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

		return $context->setCache( $cache );
	}
721659
protected function fromArray( \Aimeos\MShop\Coupon\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' );

		foreach( $this->getValue( $data, 'coupon.code.id', [] ) as $idx => $id )
		{
			$citem = $manager->createItem();

			$citem->setId( $id );
			$citem->setParentId( $item->getId() );
			$citem->setCode( $this->getValue( $data, 'coupon.code.code/' . $idx ) );
			$citem->setCount( $this->getValue( $data, 'coupon.code.count/' . $idx ) );
			$citem->setDateStart( $this->getValue( $data, 'coupon.code.datestart/' . $idx ) );
			$citem->setDateEnd( $this->getValue( $data, 'coupon.code.dateend/' . $idx ) );

			$manager->saveItem( $citem, false );
		}
	}
877683
protected function getSiteIdsFromTree( \Aimeos\MShop\Locale\Item\Site\Iface $item )
	{
		$list = array( $item->getId() );

		foreach( $item->getChildren() as $child ) {
			$list = array_merge( $list, $this->getSiteIdsFromTree( $child ) );
		}

		return $list;
	}
171666
protected function createNodeArray( \Aimeos\MShop\Catalog\Item\Iface $node )
	{
		$result = $node->toArray( true );

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

		return (object) $result;
	}
66121
public function save( \Aimeos\MShop\Subscription\Item\Iface $item )
	{
		return $this->controller->save( $item );
	}
189099
protected function addDownload( \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item )
	{
		$fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' );
		$response = $this->getView()->response();
		$value = (string) $item->getValue();

		if( $fs->has( $value ) )
		{
			$name = $item->getName();

			if( pathinfo( $name, PATHINFO_EXTENSION ) == null
					&& ( $ext = pathinfo( $value, PATHINFO_EXTENSION ) ) != null
			) {
				$name .= '.' . $ext;
			}

			$response->withHeader( 'Content-Description', 'File Transfer' );
			$response->withHeader( 'Content-Type', 'application/octet-stream' );
			$response->withHeader( 'Content-Disposition', 'attachment; filename="' . $name . '"' );
			$response->withHeader( 'Content-Length', (string) $fs->size( $value ) );
			$response->withHeader( 'Cache-Control', 'must-revalidate' );
			$response->withHeader( 'Pragma', 'private' );
			$response->withHeader( 'Expires', '0' );

			$response->withBody( $response->createStream( $fs->reads( $value ) ) );
		}
		elseif( filter_var( $value, FILTER_VALIDATE_URL ) !== false )
		{
			$response->withHeader( 'Location', $value );
			$response->withStatus( 303 );
		}
		else
		{
			$response->withStatus( 404 );
		}
	}
402974
protected function fromArray( \Aimeos\MShop\Attribute\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute/property' );

		$propItems = $item->getPropertyItems( null, false );

		foreach( $data as $entry )
		{
			if( isset( $propItems[$entry['attribute.property.id']] ) )
			{
				$propItem = $propItems[$entry['attribute.property.id']];
				unset( $propItems[$entry['attribute.property.id']] );
			}
			else
			{
				$propItem = $manager->createItem();
			}

			$propItem->fromArray( $entry, true );
			$item->addPropertyItem( $propItem );
		}

		$item->deletePropertyItems( $propItems );
	}
1203192
protected function prepareItem(array $item, array $data)
    {
        $product = $this->product->getBySku($item['sku'], $item['store_id']);

        if (empty($product['status']) || $data['store_id'] != $product['store_id']) {
            return array();
        }

        $product['price'] = $this->currency->convert($product['price'], $product['currency'], $data['currency']);

        $calculated = $this->product->calculate($product);

        if ($calculated != $product['price']) {
            $item['original_price'] = $product['price'];
        }

        $item['product'] = $product;
        $item['price'] = $calculated;
        $item['total'] = $item['price'] * $item['quantity'];

        return $item;
    }
429803
protected function _createNodeArray( MShop_Locale_Item_Site_Interface $item )
	{
		$result = $item->toArray();

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

		return (object) $result;
	}
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;
	}
386963
protected function addViewData( \Aimeos\MW\View\Iface $view )
	{
		$context = $this->getContext();

		$textTypeManager = \Aimeos\MShop::create( $context, 'text/type' );
		$listTypeManager = \Aimeos\MShop::create( $context, 'product/lists/type' );

		$search = $textTypeManager->createSearch( true )->setSlice( 0, 10000 );
		$search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) );
		$search->setSortations( array( $search->sort( '+', 'text.type.position' ) ) );

		$listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 );
		$listSearch->setConditions( $listSearch->compare( '==', 'product.lists.type.domain', 'text' ) );
		$listSearch->setSortations( array( $listSearch->sort( '+', 'product.lists.type.position' ) ) );

		$view->textTypes = $this->map( $textTypeManager->searchItems( $search ) );
		$view->textListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) );

		return $view;
	}
293020
public function getViewUrlFor($item)
    {
        if (is_object($item)) {
            $id = $item->getid();
        } else {
            $id = $item['id'];
        }
        $params = ['id' => $id];
        $params = array_merge($params, $this->getExtraParameters());

        return [
            'path' => $this->getPathByConvention($this::SUFFIX_VIEW),
            'params' => $params,
        ];
    }
15182
protected function toArray( \Aimeos\MShop\Coupon\Item\Iface $item, $copy = false )
	{
		$config = $item->getConfig();
		$data = $item->toArray( true );
		$data['config'] = [];

		if( $copy === true )
		{
			$data['coupon.siteid'] = $this->getContext()->getLocale()->getSiteId();
			$data['coupon.id'] = '';
		}

		ksort( $config );

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

		return $data;
	}