protected function _getSameProduct( MShop_Order_Item_Base_Product_Interface $item )
	{
		$attributeMap = array();

		foreach( $item->getAttributes() as $attributeItem ) {
			$attributeMap[ $attributeItem->getCode() ] = $attributeItem;
		}

		foreach( $this->_products as $position => $product )
		{
			if( $product->compare( $item ) === false ) {
				continue;
			}

			$prodAttributes = $product->getAttributes();

			if( count( $prodAttributes ) !== count( $attributeMap ) ) {
				continue;
			}

			foreach( $prodAttributes as $attribute )
			{
				if( array_key_exists( $attribute->getCode(), $attributeMap ) === false
					|| $attributeMap[ $attribute->getCode() ]->getValue() != $attribute->getValue() ) {
					continue 2; // jump to outer loop
				}
			}

			return $position;
		}

		return false;
	}
protected function _getSameProduct( MShop_Order_Item_Base_Product_Interface $item )
	{
		$attributeMap = array();

		foreach( $item->getAttributes() as $attributeItem ) {
			$attributeMap[ $attributeItem->getCode() ] = $attributeItem;
		}

		foreach( $this->_products as $position => $product )
		{
			if( $product->compare( $item ) === false ) {
				continue;
			}

			$prodAttributes = $product->getAttributes();

			if( count( $prodAttributes ) !== count( $attributeMap ) ) {
				continue;
			}

			foreach( $prodAttributes as $attribute )
			{
				if( array_key_exists( $attribute->getCode(), $attributeMap ) === false
					|| $attributeMap[ $attribute->getCode() ]->getValue() != $attribute->getValue() ) {
					continue 2; // jump to outer loop
				}
			}

			return $position;
		}

		return false;
	}
protected function _getSameProduct ( MShop_Order_Item_Base_Product_Interface $ item ) { $ attributeMap = array ( ) ; foreach ( $ item -> getAttributes ( ) as $ attributeItem ) { $ attributeMap [ $ attributeItem -> getCode ( ) ] = $ attributeItem ; } foreach ( $ this -> _products as $ position => $ product ) { if ( $ product -> compare ( $ item ) === false ) { continue ; } $ prodAttributes = $ product -> getAttributes ( ) ; if ( count ( $ prodAttributes ) !== count ( $ attributeMap ) ) { continue ; } foreach ( $ prodAttributes as $ attribute ) { if ( array_key_exists ( $ attribute -> getCode ( ) , $ attributeMap ) === false || $ attributeMap [ $ attribute -> getCode ( ) ] -> getValue ( ) != $ attribute -> getValue ( ) ) { continue 2 ; // jump to outer loop } } return $ position ; } return false ; }
Tests if the given product is similar to an existing one.
Similarity is described by the equality of properties so the quantity of
the existing product can be updated.

@param MShop_Order_Item_Base_Product_Interface $item Order product item
@return integer Positon of the same product in the product list
@throws MShop_Order_Exception If no similar item was found
Tests if the given product is similar to an existing one . Similarity is described by the equality of properties so the quantity of the existing product can be updated .