Jump to content
rezhisser

Проблемы с сохранением нового поля в oc_manufacturer (editManufacturer)

Recommended Posts

Добавил в таблицу oc_manufacturer два поля

  • status    tinyint(1)
  • cost_percent     int(11)

 

и вывел их в форме Производителя в админке

 

В итоге со status все ок (считывает и обновляет), а с cost_percent - проблемы (с бд получает данные, но при обновлении обнуляет в бд значения)

 

В модели изменял только две функции

 

editManufacturer

		$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "', status = 	'" . (int)$data['status'] . "', cost_percent = 	'" . (int)$data['cost_percent'] . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");

и

getManufacturers

		$sql = "SELECT c.manufacturer_id, md.name, c.sort_order, c.status, c.cost_percent FROM " . DB_PREFIX . "manufacturer c LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (c.manufacturer_id = md.manufacturer_id) WHERE md.language_id = '" . (int)$this->config->get('config_language_id') . "'";

 

В контроллере добавилось

 

		if (isset($this->request->post['status'])) {
			$data['status'] = $this->request->post['status'];
		} elseif (!empty($manufacturer_info)) {
			$data['status'] = $manufacturer_info['status'];
		} else {
			$data['status'] = true;
		}
		
		if (isset($this->request->post['cost_percent'])) {
			$data['cost_percent'] = $this->request->post['cost_percent'];
		} elseif (!empty($manufacturer_info)) {
			$data['cost_percent'] = $manufacturer_info['cost_percent'];
		} else {
			$data['cost_percent'] = true;
		}

 

Не могу понять, что не так...

Share this post


Link to post
Share on other sites

код из шаблона добавьте

Share this post


Link to post
Share on other sites

@Pavel666 да, в шаблоне была ошибка. спасибо за наводку.

 

с таким кодом все работает

		  <div class="form-group">
                <label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
                <div class="col-sm-10">
                  <select name="status" id="input-status" class="form-control">
                    <?php if ($status) { ?>
                    <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                    <option value="0"><?php echo $text_disabled; ?></option>
                    <?php } else { ?>
                    <option value="1"><?php echo $text_enabled; ?></option>
                    <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                    <?php } ?>
                  </select>
                </div>
              </div>
			<div class="form-group">
                <label class="col-sm-2 control-label" for="input-cost_percent"><?php echo $entry_cost_percent; ?></label>
                <div class="col-sm-10">
                  <input type="text" name="cost_percent" value="<?php echo $cost_percent; ?>" placeholder="<?php echo $entry_cost_percent; ?>" id="input-cost_percent" class="form-control" />
                </div>
           </div>

вопрос снимается

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.