예제 #1
0
 public function view()
 {
     $this->set('category', AttributeKeyCategory::getByHandle('store_product'));
     $attrTypes = AttributeType::getList('store_product');
     $types = array();
     foreach ($attrTypes as $at) {
         $types[$at->getAttributeTypeID()] = $at->getAttributeTypeName();
     }
     $attrList = StoreProductKey::getList();
     $this->set('attrList', $attrList);
     $this->set('types', $types);
 }
예제 #2
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()) {
             $product = VividProduct::save($data);
             $aks = StoreProductKey::getList();
             foreach ($aks as $uak) {
                 $uak->saveAttributeForm($product);
             }
             if ($data['pID']) {
                 $this->redirect('/dashboard/store/products/', 'updated');
             } else {
                 $this->redirect('/dashboard/store/products/', 'success');
             }
         }
         //if no errors
     }
     //if post
 }
예제 #3
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
 }