Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

ngame

Newbie
  
  • Posts

    2
  • Joined

  • Last visited

ngame's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

1

Reputation

  1. Мой вариант, на основе топикстартера: 1.добавляем в таблицу __product два поля -> currency_id(int,10,NOT NULL,index),base_price(DECIMAL,10,2); 2.редактируем -> admin/model/catalog/product.php: -сразу после объявления класса, добавляет функцию: public function setDefaultCurrency($price,$currency) { if(!empty($price)) { $query = $this->db->query("SELECT value FROM " . DB_PREFIX . "currency WHERE currency_id = '" .(int)$currency. "'"); if ($query->num_rows) { return $final_price = ($price * $query->row['value']); } } } -редактируем функцию addProduct, меняя запрос к БД на этот: $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 = '" .$this->setDefaultCurrency($data['base_price'],$data['currency_id']). "', currency_id = '" . (int)$data['currency_id'] . "',base_price = '" . (float)$data['base_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()"); -редактируем функцию editProduct, меняя запрос к БД: $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 = '" .$this->setDefaultCurrency($data['base_price'],$data['currency_id']). "', currency_id = '" . (int)$data['currency_id'] . "', base_price = '" . (float)$data['base_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 . "'"); 3.редактируем -> admin/controller/catalog/product.php. В функцию getForm() добавим: if (isset($this->request->post['base_price'])) { $this->data['base_price'] = $this->request->post['base_price']; } elseif (!empty($product_info)) { $this->data['base_price'] = $product_info['base_price']; } else { $this->data['base_price'] = ' '; } $this->load->model('localisation/currency'); $this->data['currencies'] = $this->model_localisation_currency->getCurrencies(); 4.редактируем -> admin/catalog/view/template/catalog/product_form.tpl . Ищем строку таблицы, примерно выглядит вот так: <tr> <td><?php echo $entry_price; ?></td> <td><input type="text" name="price" value="<?php echo $price; ?>" /> ..... </tr> и меняем ее на эту: <tr> <td><?php echo $entry_price; ?></td> <td><input type="text" name="base_price" value="<?php echo $base_price; ?>" /> <select name="currency_id"> <?php foreach ($currencies as $currency) { ?> <?php if ($currency['currency_id'] == $currency_id) { ?> <option value="<?php echo $currency['currency_id']; ?>" selected="selected"><?php echo $currency['title']; ?></option> <?php } else { ?> <option value="<?php echo $currency['currency_id']; ?>"><?php echo $currency['title']; ?></option> <?php } ?> <?php } ?> </select></td> </tr> Всё. Настраиваем курсы и список валют в настройках магазина. Цены корректно отображаются в coolfilter,latest и т.п. Проверено на 1.5.6.4. В своем проекте я еще добавил автообновление цен при изменении курса, и вывод цены с валютой в админке, в режиме просмотра списка товаров + изменил некоторые типы ячеек БД, отвечающих за вывод продуктов.
Guest
×
  • Create New...

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.