controller/common/src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$context = $this->getContext();
		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );

		$listMap = [];
		$map = $this->getMappedChunk( $data, $this->getMapping() );
		$listItems = $product->getListItems( 'attribute', $this->listTypes );

		foreach( $listItems as $listItem )
		{
			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
				$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
			}
		}

		foreach( $map as $pos => $list )
		{
			if( $this->checkEntry( $list ) === false ) {
				continue;
			}

			$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );

			foreach( $codes as $code )
			{
				$code = trim( $code );
				$listtype = $this->getValue( $list, 'product.lists.type', 'default' );

				if( isset( $listMap[$code][$listtype] ) )
				{
					$listItem = $listMap[$code][$listtype];
					unset( $listItems[$listItem->getId()] );
				}
				else
				{
					$listItem = $listManager->createItem()->setType( $listtype );
				}

				$listItem = $listItem->setPosition( $pos )->fromArray( $list );

				$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
				$attrItem = $attrItem->setCode( $code )->fromArray( $list );

				$product->addListItem( 'attribute', $listItem, $attrItem );
			}
		}

		$product->deleteListItems( $listItems );

		return $this->getObject()->process( $product, $data );
	}
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$context = $this->getContext();
		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );

		$listMap = [];
		$map = $this->getMappedChunk( $data, $this->getMapping() );
		$listItems = $product->getListItems( 'attribute', $this->listTypes );

		foreach( $listItems as $listItem )
		{
			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
				$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
			}
		}

		foreach( $map as $pos => $list )
		{
			if( $this->checkEntry( $list ) === false ) {
				continue;
			}

			$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );

			foreach( $codes as $code )
			{
				$code = trim( $code );
				$listtype = $this->getValue( $list, 'product.lists.type', 'default' );

				if( isset( $listMap[$code][$listtype] ) )
				{
					$listItem = $listMap[$code][$listtype];
					unset( $listItems[$listItem->getId()] );
				}
				else
				{
					$listItem = $listManager->createItem()->setType( $listtype );
				}

				$listItem = $listItem->setPosition( $pos )->fromArray( $list );

				$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
				$attrItem = $attrItem->setCode( $code )->fromArray( $list );

				$product->addListItem( 'attribute', $listItem, $attrItem );
			}
		}

		$product->deleteListItems( $listItems );

		return $this->getObject()->process( $product, $data );
	}
public function process ( \ Aimeos \ MShop \ Product \ Item \ Iface $ product , array $ data ) { $ context = $ this -> getContext ( ) ; $ listManager = \ Aimeos \ MShop :: create ( $ context , 'product/lists' ) ; $ separator = $ context -> getConfig ( ) -> get ( 'controller/common/product/import/csv/separator' , "\n" ) ; $ listMap = [ ] ; $ map = $ this -> getMappedChunk ( $ data , $ this -> getMapping ( ) ) ; $ listItems = $ product -> getListItems ( 'attribute' , $ this -> listTypes ) ; foreach ( $ listItems as $ listItem ) { if ( ( $ refItem = $ listItem -> getRefItem ( ) ) !== null ) { $ listMap [ $ refItem -> getCode ( ) ] [ $ listItem -> getType ( ) ] = $ listItem ; } } foreach ( $ map as $ pos => $ list ) { if ( $ this -> checkEntry ( $ list ) === false ) { continue ; } $ codes = explode ( $ separator , $ this -> getValue ( $ list , 'attribute.code' , '' ) ) ; foreach ( $ codes as $ code ) { $ code = trim ( $ code ) ; $ listtype = $ this -> getValue ( $ list , 'product.lists.type' , 'default' ) ; if ( isset ( $ listMap [ $ code ] [ $ listtype ] ) ) { $ listItem = $ listMap [ $ code ] [ $ listtype ] ; unset ( $ listItems [ $ listItem -> getId ( ) ] ) ; } else { $ listItem = $ listManager -> createItem ( ) -> setType ( $ listtype ) ; } $ listItem = $ listItem -> setPosition ( $ pos ) -> fromArray ( $ list ) ; $ attrItem = $ this -> getAttributeItem ( $ code , $ this -> getValue ( $ list , 'attribute.type' ) ) ; $ attrItem = $ attrItem -> setCode ( $ code ) -> fromArray ( $ list ) ; $ product -> addListItem ( 'attribute' , $ listItem , $ attrItem ) ; } } $ product -> deleteListItems ( $ listItems ) ; return $ this -> getObject ( ) -> process ( $ product , $ data ) ; }
Saves the attribute related data to the storage

@param \Aimeos\MShop\Product\Item\Iface $product Product item with associated items
@param array $data List of CSV fields with position as key and data as value
@return array List of data which hasn't been imported
Saves the attribute related data to the storage