controller/common/src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );

		$propMap = [];
		$items = $product->getPropertyItems( null, false );
		$map = $this->getMappedChunk( $data, $this->getMapping() );

		foreach( $items as $item ) {
			$propMap[$item->getValue()][$item->getType()] = $item;
		}

		foreach( $map as $list )
		{
			if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) {
				continue;
			}

			if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) )
			{
				$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' );
				throw new \Aimeos\Controller\Common\Exception( $msg );
			}

			if( isset( $propMap[$value][$type] ) )
			{
				$item = $propMap[$value][$type];
				unset( $items[$item->getId()] );
			}
			else
			{
				$item = $manager->createItem()->setType( $type );
			}

			$product->addPropertyItem( $item->fromArray( $list ) );
		}

		$product->deletePropertyItems( $items );

		return $this->getObject()->process( $product, $data );
	}
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );

		$propMap = [];
		$items = $product->getPropertyItems( null, false );
		$map = $this->getMappedChunk( $data, $this->getMapping() );

		foreach( $items as $item ) {
			$propMap[$item->getValue()][$item->getType()] = $item;
		}

		foreach( $map as $list )
		{
			if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) {
				continue;
			}

			if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) )
			{
				$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' );
				throw new \Aimeos\Controller\Common\Exception( $msg );
			}

			if( isset( $propMap[$value][$type] ) )
			{
				$item = $propMap[$value][$type];
				unset( $items[$item->getId()] );
			}
			else
			{
				$item = $manager->createItem()->setType( $type );
			}

			$product->addPropertyItem( $item->fromArray( $list ) );
		}

		$product->deletePropertyItems( $items );

		return $this->getObject()->process( $product, $data );
	}
public function process ( \ Aimeos \ MShop \ Product \ Item \ Iface $ product , array $ data ) { $ manager = \ Aimeos \ MShop :: create ( $ this -> getContext ( ) , 'product/property' ) ; $ propMap = [ ] ; $ items = $ product -> getPropertyItems ( null , false ) ; $ map = $ this -> getMappedChunk ( $ data , $ this -> getMapping ( ) ) ; foreach ( $ items as $ item ) { $ propMap [ $ item -> getValue ( ) ] [ $ item -> getType ( ) ] = $ item ; } foreach ( $ map as $ list ) { if ( ( $ value = $ this -> getValue ( $ list , 'product.property.value' ) ) === null ) { continue ; } if ( ( $ type = $ this -> getValue ( $ list , 'product.property.type' ) ) && ! isset ( $ this -> types [ $ type ] ) ) { $ msg = sprintf ( 'Invalid type "%1$s" (%2$s)' , $ type , 'product property' ) ; throw new \ Aimeos \ Controller \ Common \ Exception ( $ msg ) ; } if ( isset ( $ propMap [ $ value ] [ $ type ] ) ) { $ item = $ propMap [ $ value ] [ $ type ] ; unset ( $ items [ $ item -> getId ( ) ] ) ; } else { $ item = $ manager -> createItem ( ) -> setType ( $ type ) ; } $ product -> addPropertyItem ( $ item -> fromArray ( $ list ) ) ; } $ product -> deletePropertyItems ( $ items ) ; return $ this -> getObject ( ) -> process ( $ product , $ data ) ; }
Saves the product property 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 product property related data to the storage