all(); $this->set(['cart'=>$products]); } public function add($id=null) { $this->loadModel('Products'); $product = $this->Products->find('all',[ 'conditions'=>[ 'Products.id'=>$id ] ])->first(); if (empty($product)) { throw new NotFoundException("Artefact not found - Artefato não encontrado"); } $product->qtd = 1; $cart = Cart::factory(); $cart->add($product->toArray()); return $this->redirect(['action'=>'index']); } }