protected function _getStockLevel( $prodid, $warehouse )
	{
		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock' );

		$search = $manager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'product.stock.productid', $prodid ),
			$search->getConditions(),
			$search->compare( '==', 'product.stock.warehouse.code', $warehouse ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

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

		if( empty( $result ) )
		{
			$msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse );
			throw new Controller_Frontend_Basket_Exception( $msg );
		}

		$stocklevel = null;

		foreach( $result as $item )
		{
			if( ( $stock = $item->getStockLevel() ) === null ) {
				return null;
			}

			$stocklevel = max( (int) $stocklevel, $item->getStockLevel() );
		}

		return $stocklevel;
	}
protected function _getStockLevel( $prodid, $warehouse )
	{
		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock' );

		$search = $manager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'product.stock.productid', $prodid ),
			$search->getConditions(),
			$search->compare( '==', 'product.stock.warehouse.code', $warehouse ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

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

		if( empty( $result ) )
		{
			$msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse );
			throw new Controller_Frontend_Basket_Exception( $msg );
		}

		$stocklevel = null;

		foreach( $result as $item )
		{
			if( ( $stock = $item->getStockLevel() ) === null ) {
				return null;
			}

			$stocklevel = max( (int) $stocklevel, $item->getStockLevel() );
		}

		return $stocklevel;
	}
protected function _getStockLevel ( $ prodid , $ warehouse ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product/stock' ) ; $ search = $ manager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , 'product.stock.productid' , $ prodid ) , $ search -> getConditions ( ) , $ search -> compare ( '==' , 'product.stock.warehouse.code' , $ warehouse ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ result = $ manager -> searchItems ( $ search ) ; if ( empty ( $ result ) ) { $ msg = sprintf ( 'No stock for product ID "%1$s" and warehouse "%2$s" available' , $ prodid , $ warehouse ) ; throw new Controller_Frontend_Basket_Exception ( $ msg ) ; } $ stocklevel = null ; foreach ( $ result as $ item ) { if ( ( $ stock = $ item -> getStockLevel ( ) ) === null ) { return null ; } $ stocklevel = max ( ( int ) $ stocklevel , $ item -> getStockLevel ( ) ) ; } return $ stocklevel ; }
Returns the highest stock level for the product.

@param string $prodid Unique ID of the product
@param string $warehouse Unique code of the warehouse
@return integer|null Number of available items in stock (null for unlimited stock)
Returns the highest stock level for the product .