Beispiel #1
0
 public function save()
 {
     $data = $this->post();
     if ($data['pID']) {
         $this->edit($data['pID']);
     } else {
         $this->add();
     }
     if ($this->isPost()) {
         $errors = $this->validate($data);
         $this->error = null;
         //clear errors
         $this->error = $errors;
         if (!$errors->has()) {
             //save the product
             $product = StoreProduct::saveProduct($data);
             //save product attributes
             $aks = StoreProductKey::getList();
             foreach ($aks as $uak) {
                 $uak->saveAttributeForm($product);
             }
             //save images
             StoreProductImage::addImagesForProduct($data, $product);
             //save product groups
             StoreProductGroup::addGroupsForProduct($data, $product);
             //save product user groups
             StoreProductUserGroup::addUserGroupsForProduct($data, $product);
             //save product options
             StoreProductOption::addProductOptions($data, $product);
             //save files
             StoreProductFile::addFilesForProduct($data, $product);
             //save category locations
             StoreProductLocation::addLocationsForProduct($data, $product);
             if ($data['pID']) {
                 $this->redirect('/dashboard/store/products/', 'updated');
             } else {
                 $this->redirect('/dashboard/store/products/', 'success');
             }
         }
         //if no errors
     }
     //if post
 }