Returns the item populated by the data from the row.

@param \Aimeos\MShop\Coupon\Item\Code\Iface $item Empty coupon item
@param array $row List of coupon data (code, count, start and end)
@return \Aimeos\MShop\Coupon\Item\Code\Iface Populated coupon item
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;
	}
500953
public function getWidgetItem(array $item) {
        $entity = new ItemWidget();

        $entity->setName($this->getItemName($item));
        $entity->setLink($this->browser->getHost().$item['url']);
        $entity->setCover($this->browser->getHost().$item['image']['original']);

        $catalog_item = $this->getCatalogItem($item);
        if ($catalog_item instanceof Item) {
            $entity->setItem($catalog_item);
        } elseif ($this->filler instanceof Filler) {
            $entity->setLinkForFill($this->filler->getLinkForFill($entity->getLink()));
        }

        return $entity;
    }
445945
protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
	{
		if( $item->getStatus() < 1 ) {
			return [];
		}

		$list = [ $item->getId() ];

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

		return $list;
	}
609781
public function deletePropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item )
	{
		$this->item = $this->item->deletePropertyItem( $item );
		return $this;
	}
1337709
public function save( \Aimeos\MShop\Order\Item\Iface $orderItem )
	{
		return $this->controller->save( $orderItem );
	}
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;
	}
485423
protected function getProducts( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds, $stockType )
	{
		$productCodes = $stockMap = [];
		$productItems = $this->getProductItems( $context, $prodIds );

		foreach( $productItems as $productItem ) {
			$productCodes[] = $productItem->getCode();
		}

		foreach( $this->getStockItems( $context, $productCodes, $stockType ) as $stockItem ) {
			$stockMap[ $stockItem->getProductCode() ] = true;
		}

		foreach( $productItems as $productId => $productItem )
		{
			if( !isset( $stockMap[ $productItem->getCode() ] ) ) {
				unset( $productItems[$productId] );
			}
		}

		return $productItems;
	}
161126
protected function rowToObject($row)
    {
        if ('array' == $this->returnDataType) {
            return $row;
        }

        if ($row) {
            $object = $this->createEntity();
            $this->loadObjectFromArray($object, $row);

            return $object;
        }

        return;
    }
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 );
	}
423516
protected function getItemLine(array $item)
    {
        $result = array();

        $this->addPropertySource('item', $item);

        $this->addProductInfo($result);
        $sign = $this->invoiceSource->getSign();

        // Check for cost price and margin scheme.
        if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
            // Margin scheme:
            // - Do not put VAT on invoice: send price incl VAT as unitprice.
            // - But still send the VAT rate to Acumulus.
            $result[Tag::UnitPrice] = $sign * $item['unit_price_tax_incl'];
        } else {
            $result[Tag::UnitPrice] = $sign * $item['unit_price_tax_excl'];
            $result[Meta::UnitPriceInc] = $sign * $item['unit_price_tax_incl'];
            $result[Meta::LineAmount] = $sign * $item['total_price_tax_excl'];
            $result[Meta::LineAmountInc] = $sign * $item['total_price_tax_incl'];
            if (!Number::floatsAreEqual($item['unit_amount'], $result[Meta::UnitPriceInc] - $result[Tag::UnitPrice])) {
                $result[Meta::LineDiscountVatAmount] = $item['unit_amount'] - ($result[Meta::UnitPriceInc] - $result[Tag::UnitPrice]);
            }
        }
        $result[Tag::Quantity] = $item['product_quantity'];

        // Get vat rate:
        // The field 'rate' comes from order->getOrderDetailTaxes() and is only
        // defined for orders and was not filled in before PS1.6.1.1. So, check
        // if the field is available.
        // The fields 'unit_amount' and 'total_amount' (table order_detail_tax)
        // are based on the discounted product price and thus cannot be used to
        // get the vat rate.
        if (isset($item['rate'])) {
            $result[Tag::VatRate] = $item['rate'];
            $result[Meta::VatRateSource] = Creator::VatRateSource_Exact;
        } else {
            // Precision: 1 of the amounts, probably the prince incl tax, is
            // entered by the admin and can thus be considered exact. The other
            // is calculated by the system and not rounded and can thus be
            // considered to have a precision better than 0.0001
            $result += $this->getVatRangeTags($sign * ($item['unit_price_tax_incl'] - $item['unit_price_tax_excl']),
                $sign * $item['unit_price_tax_excl'],
                $this->precision, $this->precision);
        }
        $result += $this->getVatRateLookupMetadata($this->order->id_address_invoice, $this->getItemLineTaxRuleGroupId($item));

        $result[Meta::FieldsCalculated][] = Meta::VatAmount;

        $this->removePropertySource('item');
        return $result;
    }
429767
protected function fromArray( \Aimeos\MShop\Order\Item\Base\Iface $order, array $data )
	{
		$invoiceIds = $this->getValue( $data, 'order.id', [] );
		$manager = \Aimeos\MShop::create( $this->getContext(), 'order' );

		$search = $manager->createSearch()->setSlice( 0, count( $invoiceIds ) );
		$search->setConditions( $search->compare( '==', 'order.id', $invoiceIds ) );

		$items = $manager->searchItems( $search );


		foreach( $invoiceIds as $idx => $id )
		{
			if( !isset( $items[$id] ) ) {
				$item = $manager->createItem();
			} else {
				$item = $items[$id];
			}

			if( isset( $data['order.statusdelivery'][$idx] ) ) {
				$item->setDeliveryStatus( $data['order.statusdelivery'][$idx] );
			}

			if( isset( $data['order.statuspayment'][$idx] ) ) {
				$item->setPaymentStatus( $data['order.statuspayment'][$idx] );
			}

			if( isset( $data['order.datedelivery'][$idx] ) ) {
				$item->setDateDelivery( $data['order.datedelivery'][$idx] );
			}

			if( isset( $data['order.datepayment'][$idx] ) ) {
				$item->setDatePayment( $data['order.datepayment'][$idx] );
			}

			if( isset( $data['order.relatedid'][$idx] ) ) {
				$item->setRelatedId( $data['order.relatedid'][$idx] );
			}

			if( isset( $data['order.type'][$idx] ) ) {
				$item->setType( $data['order.type'][$idx] );
			}

			$item->setBaseId( $order->getId() );

			$manager->saveItem( $item );
		}
	}
1211054
private function getDataFromItem($item)
    {
        if (!is_object($item) && !is_array($item)) {
            return array();
        }

        return is_object($item) ? get_object_vars($item) : $item;
    }
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;
	}
1137204
public static function getSiteItems( \Aimeos\MShop\Context\Item\Iface $context, $sites )
	{
		if( !is_array( $sites )  ) {
			$sites = explode( ' ', $sites );
		}

		$manager = \Aimeos\MShop::create( $context, 'locale/site' );
		$search = $manager->createSearch();

		if( !empty( $sites ) ) {
			$search->setConditions( $search->compare( '==', 'locale.site.code', $sites ) );
		}

		return $manager->searchItems( $search );
	}
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 ) );
	}
166580
public function getCell($row, $col) {
		if ($row < 2 && $this->hasOnlyCols($this->count()))
			return $this->getItem($col);
		$row=$this->getItem($row);
		if (isset($row)) {
			$col=$row->getItem($col);
		}
		return $col;
	}
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;
	}