public function deleteAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_DeleteProduct();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $data = $form->getValues();
             $productMapper = new Application_Model_ProductMapper();
             if (isset($data['product_id'])) {
                 $productMapper->delete($data['product_id']);
             }
             return $this->_helper->redirector('viewall');
         }
     }
 }
예제 #2
0
 public function deleteSelectionAction()
 {
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     if ($this->getRequest()->isPost()) {
         $selection = $this->_getParam('selection');
         if (!empty($selection)) {
             $mapper = new Application_Model_ProductMapper();
             foreach ($selection as $id) {
                 try {
                     $mapper->delete($id);
                 } catch (Exception $e) {
                     continue;
                 }
             }
             $this->view->result = 'success';
             $this->view->alert = 'Products removed from the list';
         } else {
             $this->view->result = 'warning';
             $this->view->alert = 'No products selected';
         }
     }
 }