public function __toString()
 {
     $this->__load();
     return parent::__toString();
 }
 private function AddProductsAction($dom)
 {
     foreach ($dom->documentElement->getElementsByTagName('row') as $zRow) {
         // This is the place for add products
         $producto = new Producto();
         $producto->setNombre($zRow->getAttributeNode('DESCRIP_PRODUCTO')->value);
         $producto->setCodigo($zRow->getAttributeNode('CODIGO_PRODUCTO')->value);
         $_fechaTemp = $zRow->getAttributeNode('Fecha_de_Exportacion')->value;
         $_timezone = new \DateTimeZone('UTC');
         $_dateTime = new \DateTime($_fechaTemp, $_timezone);
         $_fechaExportacion = $_dateTime->format('Y-m-d H:i:s');
         $producto->setFechaExportacion(new \DateTime($_fechaExportacion));
         $producto->setEstado($zRow->getAttributeNode('Rotacion')->value);
         $producto->setUM($zRow->getAttributeNode('UM')->value);
         $producto->setCantidad((double) $zRow->getAttributeNode('CANTIDAD')->value);
         $producto->setPrecioMN((double) $zRow->getAttributeNode('PRECIO_UNITARIO_MN')->value);
         $producto->setPrecioMLC((double) $zRow->getAttributeNode('PRECIO_UNITARIO_MLC')->value);
         $_almacenCod = $zRow->getAttributeNode('CODIGO_ALMACEN')->value;
         $_almacenDesc = $zRow->getAttributeNode('DESCRIPCION_ALMACEN')->value;
         $_almacen = $this->GetAlmacenByAction($_almacenCod, $_almacenDesc);
         $producto->setAlmacen($_almacen);
         $_categoriaName = $zRow->getAttributeNode('DESCRIPCION_CATEGORIA')->value;
         $_categoria = $this->GetCategoriaByAction($_categoriaName);
         $producto->setCategoria($_categoria);
         $_centroSiglas = $zRow->getAttributeNode('SIGLAS_Entidad')->value;
         try {
             $_centro = $this->GetCentroByAction($_centroSiglas);
             $producto->setCentro($_centro);
         } catch (NotFoundHttpException $ex) {
             $this->generalExc['message'][] = $ex->getMessage();
             return false;
         }
         $em = $this->getDoctrine()->getManager();
         $em->persist($producto);
         $em->flush();
     }
     // we going to return the values inerted
     return true;
 }
 public function crearAction()
 {
     $peticion = $this->getRequest();
     $producto = new Producto();
     $formulario = $this->createForm(new ProductoType());
     $formulario->handleRequest($peticion);
     if ($formulario->isValid()) {
         $_newNombre = $formulario->getData()->getNombre();
         $_newCodigo = $formulario->getData()->getCodigo();
         $_newFechaExportacion = $formulario->getData()->getFechaExportacion();
         $_newEstado = $formulario->getData()->getEstado();
         $_newUM = $formulario->getData()->getUM();
         $_newCantidad = $formulario->getData()->getCantidad();
         $_newPrecioMN = $formulario->getData()->getPrecioMN();
         $_newPrecioMLC = $formulario->getData()->getPrecioMLC();
         $_newAlmacen = $formulario->getData()->getAlmacen();
         $_newCategoria = $formulario->getData()->getCategoria();
         $_newCentro = $formulario->getData()->getCentro();
         $producto->setNombre($_newNombre);
         $producto->setCodigo($_newCodigo);
         $producto->setFechaExportacion($_newFechaExportacion);
         $producto->setEstado($_newEstado);
         $producto->setUM($_newUM);
         $producto->setCantidad($_newCantidad);
         $producto->setPrecioMN($_newPrecioMN);
         $producto->setPrecioMLC($_newPrecioMLC);
         $producto->setAlmacen($_newAlmacen);
         $producto->setCategoria($_newCategoria);
         $producto->setCentro($_newCentro);
         $em = $this->getDoctrine()->getManager();
         $em->persist($producto);
         $em->flush();
         return $this->redirect($this->generateUrl('admin_producto_index'));
     }
     return $this->render('AdminBundle:Producto:crear.html.twig', array('producto' => $producto, 'form' => $formulario->createView()));
 }