Exemplo n.º 1
0
 public function editProductsAction()
 {
     $productsString = $this->getRequest()->getParam('products');
     $idGroup = $this->getRequest()->getParam('id');
     $products = explode(',', $productsString);
     foreach ($products as $key => $idProductGroups) {
         //all products that need to be in the table
         $modelGroup = new Default_Model_ProductGroups();
         $modelGroup->setIdProduct($idProductGroups);
         $modelGroup->setIdGroup($idGroup);
         $modelGroupFind = new Default_Model_ProductGroups();
         $selectFind = $modelGroupFind->getMapper()->getDbTable()->select()->where('idProduct = ?', $idProductGroups)->where('idGroup = ?', $idGroup);
         $modelGroupFind->fetchRow($selectFind);
         if ($modelGroupFind->getId() == NULL) {
             //existing product added in the database
             $modelGroup->setOrder($key);
             $modelGroup->save();
         }
     }
 }