для версии 1.5.3
при редактировании цены у опции укажите =, например
=100
тогда двиг сам посчитает и укажет + или -
Index: admin/model/catalog/product.php
===================================================================
--- admin/model/catalog/product.php (revision 44:90e85bd8f0dc)
+++ admin/model/catalog/product.php (revision 44+:90e85bd8f0dc+)
@@ -40,6 +40,15 @@
if (isset($product_option['product_option_value'])) {
foreach ($product_option['product_option_value'] as $product_option_value) {
+ if(strlen($product_option_value['price']) > 0 && $product_option_value['price'][0] == '=') {
+ $option_price = (float)$data['price'] - (float)substr($product_option_value['price'], 1);
+ if($option_price < 0) {
+ $product_option_value['price'] = -$option_price;
+ $product_option_value['price_prefix'] = "+";
+ } else {
+ $product_option_value['price_prefix'] = "-";
+ }
+ }
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
}
}
@@ -173,6 +182,15 @@
if (isset($product_option['product_option_value'])) {
foreach ($product_option['product_option_value'] as $product_option_value) {
+ if(strlen($product_option_value['price']) > 0 && $product_option_value['price'][0] == '=') {
+ $option_price = (float)$data['price'] - (float)substr($product_option_value['price'], 1);
+ if($option_price < 0) {
+ $product_option_value['price'] = -$option_price;
+ $product_option_value['price_prefix'] = "+";
+ } else {
+ $product_option_value['price_prefix'] = "-";
+ }
+ }
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "', product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
}
}