public function updateCartAction()
 {
     header('Content-Type: application/json');
     $t = $this->getPostData();
     $getSS = $this->app['session']->get('cart');
     $id = $t['id'];
     $getSS[$id] = abs($t['qty']);
     $this->app['session']->set('cart', $getSS);
     // $sum = $this->totalCart();
     // var_dump($sum);
     $sum = 0;
     $getSS = $this->app['session']->get('cart');
     foreach ($getSS as $id => $qty) {
         $p = Product::getById($id);
         $sum = $sum + $p[0]['price'] * $qty;
     }
     return json_encode(array('qty' => abs($t['qty']), 'sum' => $sum));
 }
 public function updateAction($id)
 {
     if ($this->getPostData()) {
         $product = $this->getPostData();
         // $postData = $this->getPostData();
         // $product['name'] = $postData['name'];
         // $product['price'] = $postData['price'];
         // $product['description'] = $postData['description'];
         // $product['qty'] = $postData['qty'];
         // $product['short_description'] = $postData['short_description'];
         // $product['type'] = $postData['type'];
         //img upload
         $product['feature_img'] = "img/product/" . $_FILES['image']['name'];
         $path = 'img/product/' . $_FILES['image']['name'];
         // Đường dẫn chưa file upload
         move_uploaded_file($_FILES['image']['tmp_name'], $path);
         //end img upload
         Product::updateProduct($id, $product);
         return $this->redirect('viewproduct');
     }
     $data = array();
     $data['product'] = Product::getById($id);
     return $this->render('admin/updateproduct.html.twig', $data);
 }
 public function detailPageAction($id)
 {
     $data['product'] = Product::getById($id);
     return $this->render('product/detailpage.html.twig', $data);
 }