这个.xml文件和vqmod在我的openchart的产品发布类型中创建了我的新自定义帖子字段。
<modification>
<id>Custom Field - unit_price</id>
<version>1</version>
<vqmver>1.0.8</vqmver>
<author>Jonathan de Jong - tigerton.se</author>
<file name="admin/language/english/catalog/product.php">
<operation>
<search position="after"><![CDATA[
$_['entry_model'] = 'Model:';
]]></search>
<add><![CDATA[
$_['entry_unit_price'] = 'unit_price:';
]]></add>
</operation>
</file>
<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']) . "', 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 = '" . $this->db->escape($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']) . "', 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'] . "', unit_price = '" . $this->db->escape($data['unit_price']) . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . $this->db->escape($data['tax_class_id']) . "', sort_order = '" . (int)$data['sort_order'] . "', 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']) . "', 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 = '" . $this->db->escape($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']) . "', 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'] . "', unit_price = '" . $this->db->escape($data['unit_price']) . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . $this->db->escape($data['tax_class_id']) . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
]]></add>
</operation>
</file>
<file name="admin/controller/catalog/product.php">
<operation>
<search position="after"><![CDATA[
$this->data['entry_model'] = $this->language->get('entry_model');
]]></search>
<add><![CDATA[
$this->data['entry_unit_price'] = $this->language->get('entry_unit_price');
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if (isset($this->request->post['sku'])) {
]]></search>
<add><![CDATA[
if (isset($this->request->post['unit_price'])) {
$this->data['unit_price'] = $this->request->post['unit_price'];
} elseif (!empty($product_info)) {
$this->data['unit_price'] = $product_info['unit_price'];
} else {
$this->data['unit_price'] = '';
}
]]></add>
</operation>
</file>
<file name="admin/view/template/catalog/product_form.tpl">
<operation>
<search position="after" offset="10"><![CDATA[
<td><?php echo $entry_weight_class; ?></td>
]]></search>
<add><![CDATA[
<tr>
<td><?php echo $entry_unit_price; ?></td>
<td><input type="text" name="unit_price" value="<?php echo $unit_price; ?>" /></td>
</td>
</tr>
]]></add>
</operation>
</file>
<file name="catalog/controller/product/product.php">
<operation error="skip">
<search position="after"><![CDATA[
$this->data['text_model'] = $this->language->get('text_model');
]]></search>
<add><![CDATA[
$this->data['text_unit_price'] = $this->language->get('text_unit_price');
]]></add>
</operation>
</file>
<file name="catalog/language/english/product/product.php">
<operation error="skip">
<search position="after"><![CDATA[
$_['tab_related'] = 'Related Products';
]]></search>
<add><![CDATA[
$_['text_unit_price'] = 'unit_price:';
]]></add>
</operation>
</file>
<file name="catalog/language/english/product/product.php">
<operation error="skip">
<search position="after"><![CDATA[
$_['tab_related'] = 'Relaterade produkter';
]]></search>
<add><![CDATA[
$_['text_unit_price'] = 'unit_price:';
]]></add>
</operation>
</file>
<file name="catalog/controller/product/product.php">
<operation error="skip">
<search position="after"><![CDATA[
$this->data['manufacturer'] = $product_info['manufacturer'];
]]></search>
<add><![CDATA[
$this->data['unit_price'] = $product_info['unit_price'];
]]></add>
</operation>
</file>
</modification>
效果很好!
事情是它现在是最后一个
有没有办法让它成为“价格”字段的下一个字段?
若然,怎么样?
感谢
答案 0 :(得分:0)
在此部分内:
<file name="admin/view/template/catalog/product_form.tpl">
<operation>
<search position="after" offset="10"><![CDATA[
<td><?php echo $entry_weight_class; ?></td>
]]></search>
<add><![CDATA[
<tr>
<td><?php echo $entry_unit_price; ?></td>
<td><input type="text" name="unit_price" value="<?php echo $unit_price; ?>" /></td>
</td> <!-- <- ALSO REMOVE THAT LINE FROM YOUR XML FILE... -->
</tr>
]]></add>
</operation>
</file>
将<search>
部分更改为:
<search position="after" offset="3"><![CDATA[<td><?php echo $entry_price; ?></td>]]></search>
使用偏移量进行游戏 - 这意味着将添加add
部分之后的行数。我想它应该是3,但也许你需要稍微调整一下(可能只有2)。