Jump to content
Sign in to follow this  
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • 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.