Exemple #1
0
 public function validateAttributeForm()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('catalog/attribute')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     if (!has_value($this->request->get_or_post('attribute_type_id'))) {
         $this->error['attribute_type'] = $this->language->get('error_required');
     } else {
         $this->request->post['attribute_type_id'] = $this->request->get_or_post('attribute_type_id');
     }
     if (!isset($this->request->post['required'])) {
         $this->request->post['required'] = 0;
     }
     if (has_value($this->request->post['regexp_pattern'])) {
         $this->request->post['regexp_pattern'] = trim($this->request->post['regexp_pattern']);
     }
     $this->error = array_merge($this->error, $this->attribute_manager->validateAttributeCommonData($this->request->post));
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     if (!$this->error) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Exemple #2
0
 public function update_option()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('product/product')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'product/product'), 'reset_value' => true));
     }
     //needs to validate attribute properties
     // first - prepare data for validation
     if (!isset($this->request->get['required'])) {
         $this->request->get['required'] = 0;
     }
     if (has_value($this->request->get['regexp_pattern'])) {
         $this->request->get['regexp_pattern'] = trim($this->request->get['regexp_pattern']);
     }
     $this->loadModel('catalog/product');
     $data = $this->request->get;
     $attribute_manager = new AAttribute_Manager('product_option');
     $option_info = $this->model_catalog_product->getProductOption($this->request->get['product_id'], $this->request->get['option_id']);
     $data['element_type'] = $option_info['element_type'];
     $data['attribute_type_id'] = $attribute_manager->getAttributeTypeID('product_option');
     $errors = $attribute_manager->validateAttributeCommonData($data);
     if (!$errors) {
         $this->model_catalog_product->updateProductOption($this->request->get['option_id'], $this->request->get);
     } else {
         $error = new AError('');
         return $error->toJSONResponse('', array('error_title' => implode('<br>', $errors)));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }