OpenCart 🇺🇦

Схема

public mixed addCustomField ( $data )

Аргументы

Аргумент Возможный тип Описание
$data

Описание

Метод пока еще не документирован.

Исходный код

$this->db->query("INSERT INTO `" . DB_PREFIX . "custom_field` SET type = '" . $this->db->escape($data['type']) . "', value = '" . $this->db->escape($data['value']) . "', required = '" . (int)$data['required'] . "', location = '" . $this->db->escape($data['location']) . "', position = '" . $this->db->escape($data['position']) . "', sort_order = '" . (int)$data['sort_order'] . "'");

$custom_field_id = $this->db->getLastId();

foreach ($data['custom_field_description'] as $language_id => $value) {
	$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_description SET custom_field_id = '" . (int)$custom_field_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
}

if (isset($data['custom_field_value'])) {
	foreach ($data['custom_field_value'] as $custom_field_value) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value SET custom_field_id = '" . (int)$custom_field_id . "', sort_order = '" . (int)$custom_field_value['sort_order'] . "'");

		$custom_field_value_id = $this->db->getLastId();

		foreach ($custom_field_value['custom_field_value_description'] as $language_id => $custom_field_value_description) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value_description SET custom_field_value_id = '" . (int)$custom_field_value_id . "', language_id = '" . (int)$language_id . "', custom_field_id = '" . (int)$custom_field_id . "', name = '" . $this->db->escape($custom_field_value_description['name']) . "'");
		}
	}
}