я успешно добавили пользовательское поле (source_code) к моему продукту, следуя этим учебным пособием: http://www.php-dev-zone.com/2015/01/how-to-add-custom-product-field-in.htmlOpenCart Пользовательские поля не позволяет дефиса «-»
Однако, мое поле не позволить «-» характер, хотя Я передрабил поле «model», которое позволяет использовать дефисы.
Например, если я вхожу «408000-025», поле вводит «408000» в базу данных. Если я вхожу «408000025», я получаю «408000025» в базе данных. Если я вхожу в поле «408000-025» в поле модели, я получаю «408000-025».
Как модель, так и source_code (мое настраиваемое поле) являются полями varchar (64), utf8_general_ci в моей базе данных.
Ниже мой vqmod:
<file name="admin/model/catalog/product.php">
<operation>
<search position="replace"><![CDATA[
$this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
]]></search>
<add><![CDATA[
$this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', source_code = '" . (int)$data['source_code'] . "', date_added = NOW()");
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
$this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
]]></search>
<add><![CDATA[
$this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', source_code = '" . (int)$data['source_code'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
]]></add>
</operation>
</file>
<file name="admin/controller/catalog/product.php">
<operation>
<search position="after"><![CDATA[
$data['entry_sort_order'] = $this->language->get('entry_sort_order');
]]></search>
<add><![CDATA[
$data['entry_source_code'] = $this->language->get('entry_source_code');
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
$data['help_isbn'] = $this->language->get('help_isbn');
]]></search>
<add><![CDATA[
$data['help_source_code'] = $this->language->get('help_source_code');
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if (isset($this->request->post['mpn'])) {
]]></search>
<add><![CDATA[
if (isset($this->request->post['source_code'])) {
$data['source_code'] = $this->request->post['source_code'];
} elseif (!empty($product_info)) {
$data['source_code'] = $product_info['source_code'];
} else {
$data['source_code'] = '';
}
]]></add>
</operation>
</file>
<file name="admin/view/template/catalog/product_form.tpl">
<operation>
<search position="after"><![CDATA[
<div class="tab-pane" id="tab-data">
]]></search>
<add><![CDATA[
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-source_code">
<span data-toggle="tooltip" title="<?php echo $help_source_code; ?>"><?php echo $entry_source_code; ?></span>
</label>
<div class="col-sm-10">
<input type="text" name="source_code" value="<?php echo $source_code; ?>" id="input-source_code" placeholder="<?php echo $entry_source_code; ?>" class="form-control" />
</div>
</div>
]]></add>
</operation>
</file>
<file name="admin/language/english/catalog/product.php">
<operation>
<search position="after"><![CDATA[
$_['entry_recurring'] = 'Recurring Profile';
]]></search>
<add><![CDATA[
$_['entry_source_code'] = 'Source Code';
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
$_['help_tag'] = 'comma separated';
]]></search>
<add><![CDATA[
$_['help_source_code'] = 'ACS Billing Code';
]]></add>
</operation>
</file>
Большое спасибо за то, что поймали! – Becca