protected function _createProduct( $productCode, $quantity = 1, $warehouse = 'default' )
	{
		$productManager = MShop_Factory::createManager( $this->_context, 'product' );
		$search = $productManager->createSearch( true );
		$search->setConditions( $search->compare( '==', 'product.code', $productCode ) );
		$products = $productManager->searchItems( $search, array( 'text', 'media', 'price' ) );

		if( ( $product = reset( $products ) ) === false ) {
			throw new MShop_Coupon_Exception( sprintf( 'No product with code "%1$s" found', $productCode ) );
		}

		$priceManager = MShop_Factory::createManager( $this->_context, 'price' );
		$prices = $product->getRefItems( 'price', 'default', 'default' );

		if( empty( $prices ) ) {
			$price = $priceManager->createItem();
		} else {
			$price = $priceManager->getLowestPrice( $prices, $quantity );
		}

		$orderBaseProductManager = MShop_Factory::createManager( $this->_context, 'order/base/product' );
		$orderProduct = $orderBaseProductManager->createItem();

		$orderProduct->copyFrom( $product );
		$orderProduct->setQuantity( $quantity );
		$orderProduct->setWarehouseCode( $warehouse );
		$orderProduct->setPrice( $price );
		$orderProduct->setFlags( MShop_Order_Item_Base_Product_Abstract::FLAG_IMMUTABLE );

		return $orderProduct;
	}
protected function _createProduct( $productCode, $quantity = 1, $warehouse = 'default' )
	{
		$productManager = MShop_Factory::createManager( $this->_context, 'product' );
		$search = $productManager->createSearch( true );
		$search->setConditions( $search->compare( '==', 'product.code', $productCode ) );
		$products = $productManager->searchItems( $search, array( 'text', 'media', 'price' ) );

		if( ( $product = reset( $products ) ) === false ) {
			throw new MShop_Coupon_Exception( sprintf( 'No product with code "%1$s" found', $productCode ) );
		}

		$priceManager = MShop_Factory::createManager( $this->_context, 'price' );
		$prices = $product->getRefItems( 'price', 'default', 'default' );

		if( empty( $prices ) ) {
			$price = $priceManager->createItem();
		} else {
			$price = $priceManager->getLowestPrice( $prices, $quantity );
		}

		$orderBaseProductManager = MShop_Factory::createManager( $this->_context, 'order/base/product' );
		$orderProduct = $orderBaseProductManager->createItem();

		$orderProduct->copyFrom( $product );
		$orderProduct->setQuantity( $quantity );
		$orderProduct->setWarehouseCode( $warehouse );
		$orderProduct->setPrice( $price );
		$orderProduct->setFlags( MShop_Order_Item_Base_Product_Abstract::FLAG_IMMUTABLE );

		return $orderProduct;
	}
protected function _createProduct ( $ productCode , $ quantity = 1 , $ warehouse = 'default' ) { $ productManager = MShop_Factory :: createManager ( $ this -> _context , 'product' ) ; $ search = $ productManager -> createSearch ( true ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.code' , $ productCode ) ) ; $ products = $ productManager -> searchItems ( $ search , array ( 'text' , 'media' , 'price' ) ) ; if ( ( $ product = reset ( $ products ) ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'No product with code "%1$s" found' , $ productCode ) ) ; } $ priceManager = MShop_Factory :: createManager ( $ this -> _context , 'price' ) ; $ prices = $ product -> getRefItems ( 'price' , 'default' , 'default' ) ; if ( empty ( $ prices ) ) { $ price = $ priceManager -> createItem ( ) ; } else { $ price = $ priceManager -> getLowestPrice ( $ prices , $ quantity ) ; } $ orderBaseProductManager = MShop_Factory :: createManager ( $ this -> _context , 'order/base/product' ) ; $ orderProduct = $ orderBaseProductManager -> createItem ( ) ; $ orderProduct -> copyFrom ( $ product ) ; $ orderProduct -> setQuantity ( $ quantity ) ; $ orderProduct -> setWarehouseCode ( $ warehouse ) ; $ orderProduct -> setPrice ( $ price ) ; $ orderProduct -> setFlags ( MShop_Order_Item_Base_Product_Abstract :: FLAG_IMMUTABLE ) ; return $ orderProduct ; }
Creates an order product from the product item.

@param string $productCode Unique product code
@param integer $quantity Number of products in basket
@param string $warehouse Unique code of the warehouse the product is from
@return MShop_Order_Item_Base_Product_Interface Ordered product
Creates an order product from the product item .