public function updateAction($id) { $this->view->categorias = Categorias::getDados(); $produto = Produtos::findById($id); $arr = array(); if (!empty($produto->imagens)) { $imagens = Imagens::find("id in (" . implode(',', $produto->imagens) . ")"); for ($i = 0; $i < count($produto->imagens); $i++) { foreach ($imagens as $key => $value) { if ($value->id == $produto->imagens[$i]) { $arr[] = $value; } } } } $this->view->imagens = (object) $arr; $this->view->form = new ProdutoForm($produto, array('edit' => true)); $this->view->relacionado_form = new ProdutosRelacionadosForm($produto, array('edit' => true)); $form = array(); if ($this->ecommerce_options->produto_detalhes == '1') { foreach ($produto->detalhes as $key => $value) { $form[] = new ProdutoDetalheForm((object) $value, array('edit' => true)); } $this->view->form_detalhes = $form; } if ($this->request->isPost()) { $this->save($produto); } $this->view->produto = $produto; }
public function indexAction() { $this->view->categorias = Categorias::getDados(); }