public function insereProduto($nome, $marca, $descricao, $subcategoria) { $produtoDAO = new ProdutoDAO(); $produto = new Produto(); $produto->setNome($nome); $produto->setMarca($marca); $produto->setDescricao($descricao); $subcategoria_nova = new SubCategoria(); $subcategoria_nova->setId_subcategoria($subcategoria); $produtoDAO->insereProduto($produto, $subcategoria_nova); return "ok"; }
public function listar($ordem = "ASC", $campo = self::ID) { $info = parent::listar($ordem, $campo); if (!empty($info)) { $temp = new Produto($info[self::ID]); parent::resgatarObjetos($info); //$l = new ListaProdutos; //$l->condicoes('', $info[self::PRODUTOPAI], self::ID); //if($l->getTotal() > 0) //$temp->setProdutoPai($l->listar(), $this->carregarDadosPai); if (!empty($info[self::NOME])) { $temp->nome = $info[self::NOME]; } if ($info[self::PESO] > 0) { $temp->peso = $info[self::PESO]; } if ($info[self::LARGURA] > 0) { $temp->largura = $info[self::LARGURA]; } if ($info[self::ALTURA] > 0) { $temp->altura = $info[self::ALTURA]; } if ($info[self::COMPRIMENTO] > 0) { $temp->comprimento = $info[self::COMPRIMENTO]; } if ($info[self::VALORCUSTO] > 0) { $temp->valorCusto = $info[self::VALORCUSTO]; } if ($info[self::VALORREAL] > 0) { $temp->valorReal = $info[self::VALORREAL]; } if ($info[self::VALORVENDA] > 0) { $temp->valorVenda = $info[self::VALORVENDA]; } if ($info[self::FRETE] > 0) { $temp->frete = $info[self::FRETE]; } if ($info[self::TIPOPEDIDO] > 0) { $temp->tipoPedido = $info[self::TIPOPEDIDO]; } $temp->setURL($info[parent::URL]); if (trim(strip_tags($info[self::DESCRICAOPEQUENA])) != '') { $temp->descricaoPequena = $info[self::DESCRICAOPEQUENA]; } if (trim(strip_tags($info[self::DESCRICAO])) != '') { $temp->descricao = $info[self::DESCRICAO]; } if ($info[self::ORDEM] > 0) { $temp->ordem = $info[self::ORDEM]; } if ($info[self::DISPONIVEL] > 0) { $temp->disponivel = $info[self::DISPONIVEL] == self::VALOR_DISPONIVEL_TRUE ? true : false; } if ($info[self::PROMOCAO] > 0) { $temp->promocao = $info[self::PROMOCAO] == self::VALOR_DISPONIVEL_TRUE ? true : false; } if ($info[self::LANCAMENTO] > 0) { $temp->lancamento = $info[self::LANCAMENTO] == self::VALOR_DISPONIVEL_TRUE ? true : false; } if ($info[self::DESTAQUE] > 0) { $temp->destaque = $info[self::DESTAQUE] == self::VALOR_DISPONIVEL_TRUE ? true : false; } if ($info[self::REMOVIDO] > 0 && !$temp->removido) { $temp->removido = $info[self::REMOVIDO] == self::VALOR_DISPONIVEL_TRUE ? true : false; } if (!empty($info[self::TIPOUNIDADE])) { $temp->tipoUnidade = $info[self::TIPOUNIDADE]; } if ($info[self::QUANTIDADEU] > 0) { $temp->quantidadeu = $info[self::QUANTIDADEU]; } if ($info[self::ESTOQUE] > 0) { $temp->estoque = $info[self::ESTOQUE]; } if (!empty($info[self::CODIGO])) { $temp->codigo = $info[self::CODIGO]; } if (!empty($info[self::VIDEO])) { $temp->setVideo($info[self::VIDEO]); } $temp->setDataCadastro(new DataHora($info[self::DATACADASTRO])); $lPM = new ListaProdutoMarcas(); $lPM->condicoes('', $info[self::MARCA], ListaProdutoMarcas::ID); if ($lPM->getTotal() > 0) { $temp->setMarca($lPM->listar()); } if ($temp->getMarca()->getId() == 182 || $temp->getMarca()->getId() == 160) { $temp->valorReal = 0; $temp->valorVenda = 0; } return $temp; } }
$p->tipoPedido = $_POST['tipoPedido']; $p->palavrasChaves = $_POST['palavrasChaves']; if (trim(strip_tags($_POST['descricaoPequena'])) != '') { $p->descricaoPequena = $_POST['descricaoPequena']; } if (trim(strip_tags($_POST['descricao'])) != '') { $p->descricao = $_POST['descricao']; } $p->frete = $_POST['frete']; if (empty($_POST['frete']) && $p->getProdutoPai() == '') { $p->frete = Produto::FRETE_NORMAL; } $lPM = new ListaProdutoMarcas(); $lPM->condicoes('', $_POST['marca'], ListaProdutoMarcas::ID); if ($lPM->getTotal() > 0) { $p->setMarca($lPM->listar()); } $p->disponivel = $_POST['disponivel'] == ListaProdutos::VALOR_DISPONIVEL_TRUE ? true : false; $p->lancamento = $_POST['lancamento'] == ListaProdutos::VALOR_DISPONIVEL_TRUE ? true : false; $p->destaque = $_POST['destaque'] == ListaProdutos::VALOR_DISPONIVEL_TRUE ? true : false; $p->promocao = $_POST['promocao'] == ListaProdutos::VALOR_DISPONIVEL_TRUE ? true : false; $p->setVideo($_POST['video']); $lP->inserir($p); $p->getURL()->setURL($_POST['url'] ? $_POST['url'] : $p->getId() . $p->codigo . "-" . URL::cleanURL($_POST['nome'] ? $_POST['nome'] : $produtoPai->nome)); $lP->alterar($p); if (count($_POST['opcao']) > 0) { $lPOV = new ListaProdutoOpcaoValores(); foreach ($_POST['opcao'] as $k => $v) { if (!empty($v)) { $aRPOV[1] = array('campo' => ListaProdutoOpcaoValores::OPCAO, 'valor' => $k); $aRPOV[2] = array('campo' => ListaProdutoOpcaoValores::ID, 'valor' => $v);