protected function _process()
	{
		$iface = 'MShop_Context_Item_Interface';
		if( !( $this->_additional instanceof $iface ) ) {
			throw new MW_Setup_Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) );
		}

		$this->_msg( 'Adding warehouse data', 0 );

		$ds = DIRECTORY_SEPARATOR;
		$path = dirname( __FILE__ ) . $ds . 'default' . $ds . 'data' . $ds . 'warehouse.php';

		if( ( $data = include( $path ) ) == false ) {
			throw new MShop_Exception( sprintf( 'No file "%1$s" found for product stock domain', $path ) );
		}

		$manager = MShop_Product_Manager_Factory::createManager( $this->_additional );
		$warehouseManager = $manager->getSubManager( 'stock' )->getSubManager( 'warehouse' );

		$num = $total = 0;
		$item = $warehouseManager->createItem();

		foreach( $data['warehouse'] as $key => $dataset )
		{
			$total++;

			$item->setId( null );
			$item->setCode( $dataset['code'] );
			$item->setLabel( $dataset['label'] );
			$item->setStatus( $dataset['status'] );

			try {
				$warehouseManager->saveItem( $item );
				$num++;
			} catch( MW_DB_Exception $e ) { ; } // if warehouse was already available
		}

		$this->_status( $num > 0 ? $num . '/' . $total : 'OK' );
	}
protected function _process()
	{
		$iface = 'MShop_Context_Item_Interface';
		if( !( $this->_additional instanceof $iface ) ) {
			throw new MW_Setup_Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) );
		}

		$this->_msg( 'Adding warehouse data', 0 );

		$ds = DIRECTORY_SEPARATOR;
		$path = dirname( __FILE__ ) . $ds . 'default' . $ds . 'data' . $ds . 'warehouse.php';

		if( ( $data = include( $path ) ) == false ) {
			throw new MShop_Exception( sprintf( 'No file "%1$s" found for product stock domain', $path ) );
		}

		$manager = MShop_Product_Manager_Factory::createManager( $this->_additional );
		$warehouseManager = $manager->getSubManager( 'stock' )->getSubManager( 'warehouse' );

		$num = $total = 0;
		$item = $warehouseManager->createItem();

		foreach( $data['warehouse'] as $key => $dataset )
		{
			$total++;

			$item->setId( null );
			$item->setCode( $dataset['code'] );
			$item->setLabel( $dataset['label'] );
			$item->setStatus( $dataset['status'] );

			try {
				$warehouseManager->saveItem( $item );
				$num++;
			} catch( MW_DB_Exception $e ) { ; } // if warehouse was already available
		}

		$this->_status( $num > 0 ? $num . '/' . $total : 'OK' );
	}
protected function _process ( ) { $ iface = 'MShop_Context_Item_Interface' ; if ( ! ( $ this -> _additional instanceof $ iface ) ) { throw new MW_Setup_Exception ( sprintf ( 'Additionally provided object is not of type "%1$s"' , $ iface ) ) ; } $ this -> _msg ( 'Adding warehouse data' , 0 ) ; $ ds = DIRECTORY_SEPARATOR ; $ path = dirname ( __FILE__ ) . $ ds . 'default' . $ ds . 'data' . $ ds . 'warehouse.php' ; if ( ( $ data = include ( $ path ) ) == false ) { throw new MShop_Exception ( sprintf ( 'No file "%1$s" found for product stock domain' , $ path ) ) ; } $ manager = MShop_Product_Manager_Factory :: createManager ( $ this -> _additional ) ; $ warehouseManager = $ manager -> getSubManager ( 'stock' ) -> getSubManager ( 'warehouse' ) ; $ num = $ total = 0 ; $ item = $ warehouseManager -> createItem ( ) ; foreach ( $ data [ 'warehouse' ] as $ key => $ dataset ) { $ total ++ ; $ item -> setId ( null ) ; $ item -> setCode ( $ dataset [ 'code' ] ) ; $ item -> setLabel ( $ dataset [ 'label' ] ) ; $ item -> setStatus ( $ dataset [ 'status' ] ) ; try { $ warehouseManager -> saveItem ( $ item ) ; $ num ++ ; } catch ( MW_DB_Exception $ e ) { ; } // if warehouse was already available } $ this -> _status ( $ num > 0 ? $ num . '/' . $ total : 'OK' ) ; }
Adds product stock test data.
Adds product stock test data .