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

Nazgulov

Newbie
  
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Nazgulov

  1. Действуйте по аналогии с добавлением полей продукта в категорию, только внося аналогичные изменения в файлы special.php и featured.php в каталогах controller и language: https://opencartforum.com/topic/15639-dobavlenie-polei-k-produktu-opencart-1541/?do=findComment&comment=242244
  2. /catalog/controller/product/product.php: $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, /*'sellunit' => $sellunit,*/ //удалить 'special' => $special, 'rating' => $rating
  3. Попробуйте так: Отображение поля продукта в категории: /catalog/controller/product/category.php 'thumb' => $image, 'name' => $result['name'], 'sellunit' => (empty($result['sellunit'])) ? '' : $this->language->get('text_sellunit') .' '. $result['sellunit'], /catalog/language/russian/product/category.php Внести аналогичные изменения во все языковые файлы задействованных языков, например /catalog/language/ukrainian/product/category.php $_['text_price'] = 'Цена:'; $_['text_tax'] = 'Без НДС:'; $_['text_sellunit'] = 'Стоимость за:'; /catalog/view/theme/%yourtheme%/template/product/category.tpl Расширяем блок "name". <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a> <?php echo $product['sellunit']; ?></div>
  4. Дополнительные поля к описанию продукта? Платные модули? Не обязательно, Вашему вниманию способ, протестированный на магазине под управлением OpenCart версии 1.5.4.1. P.S. Не забываем про backup оригинальных файлов :-) Задача: Создание дополнительного текстового поля к описанию товара. В моем случае это будет поле "Стоимость за". Например: "Стоимость за: 1 килограмм" или "Стоимость за: 1 метр квадратный". Шаг 1. База данных. Создание столбца таблицы "product" Административная панель хостера --> управление базами данных --> выбор базы --> таблица "product" --> SQL запрос: ALTER TABLE `product` ADD `sellunit` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `shipping`ИЛИ выбор базы --> таблица "product" --> "Структура" --> "Добавить столбец" (под таблицей). В моем случае новосозданный столбец под названием 'sellunit' следует сразу после столбца 'shipping' и имеет символьный тип данных varchar с ограничением длины в 32 символа. Шаг 2. Административная часть /admin/controller/catalog/product.php Пример необходимого кода будет приводиться в окружении неизмененного кода (для удобства навигации по файлу), выделяясь отступами. Строка 563 $this->data['entry_quantity'] = $this->language->get('entry_quantity'); $this->data['entry_stock_status'] = $this->language->get('entry_stock_status'); $this->data['entry_sellunit'] = $this->language->get('entry_sellunit'); $this->data['entry_price'] = $this->language->get('entry_price'); $this->data['entry_tax_class'] = $this->language->get('entry_tax_class');Строка 849 if (isset($this->request->post['shipping'])) { $this->data['shipping'] = $this->request->post['shipping']; } elseif (!empty($product_info)) { $this->data['shipping'] = $product_info['shipping']; } else { $this->data['shipping'] = 1; } if (isset($this->request->post['sellunit'])) { $this->data['sellunit'] = $this->request->post['sellunit']; } elseif (!empty($product_info)) { $this->data['sellunit'] = $product_info['sellunit']; } else { $this->data['sellunit'] = ''; } if (isset($this->request->post['price'])) { $this->data['price'] = $this->request->post['price']; } elseif (!empty($product_info)) { $this->data['price'] = $product_info['price']; } else { $this->data['price'] = ''; /admin/model/catalog/product.php В данном файле запросы к базе данных представлены в виде сплошной строки. Вынос каждого запроса в новую строку в представленном ниже коде сделан для наочности; менять структуру вовсе необязательно. Строка 4 manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', sellunit = '" . $this->db->escape($data['sellunit']) . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "',Строка 120 manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', sellunit = '" . $this->db->escape($data['sellunit']) . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', /admin/language/russian/catalog/product.php Внести аналогичные изменения во все использующиеся языковые файлы административной панели, например /admin/language/ukrainian/catalog/product.php Строка 48 $_['entry_minimum'] = 'Минимальное количество:<br/><span class="help">Указание минимально количества в заказе</span>'; $_['entry_stock_status'] = 'Остутствие на складе:<br /><span class="help">Статус, показываемый, когда товара нет на складе</span>'; $_['entry_sellunit'] = 'Стоимость за:'; $_['entry_price'] = 'Цена:'; $_['entry_tax_class'] = 'Налог:'; /admin/view/template/catalog/product_form.tpl Строка 100 <tr> <td><?php echo $entry_location; ?></td> <td><input type="text" name="location" value="<?php echo $location; ?>" /></td> </tr> <tr> <td><?php echo $entry_sellunit; ?></td> <td><input type="text" name="sellunit" value="<?php echo $sellunit; ?>" /></td> </tr> <tr> <td><?php echo $entry_price; ?></td> <td><input type="text" name="price" value="<?php echo $price; ?>" /></td> </tr> Шаг 3. Клиентская часть /catalog/controller/product/product.php Строка 150 $this->data['text_discount'] = $this->language->get('text_discount'); $this->data['text_stock'] = $this->language->get('text_stock'); $this->data['text_sellunit'] = $this->language->get('text_sellunit'); $this->data['text_price'] = $this->language->get('text_price'); $this->data['text_tax'] = $this->language->get('text_tax'); Строка 190 $this->data['reward'] = $product_info['reward']; $this->data['points'] = $product_info['points']; $this->data['sellunit'] = $product_info['sellunit']; if ($product_info['quantity'] <= 0) { $this->data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $this->data['stock'] = $product_info['quantity']; } else { $this->data['stock'] = $this->language->get('text_instock'); } /catalog/model/catalog/product.php Строка 39 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'sellunit' => $query->row['sellunit'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], /catalog/language/russian/product/product.php Внести аналогичные изменения во все языковые файлы задействованных языков, например /catalog/language/ukrainian/product/product.php Строка 11 $_['text_stock'] = 'Наличие:'; $_['text_instock'] = 'Есть в наличии'; $_['text_sellunit'] = 'Стоимость за:'; $_['text_price'] = 'Цена:'; $_['text_tax'] = 'Без НДС:'; /catalog/view/theme/%yourtheme%/template/product/product.tpl Строка 34 <div class="description"> <?php if ($manufacturer) { ?> <span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a><br /> <?php } ?> <span><?php echo $text_model; ?></span> <?php echo $model; ?><br /> <?php if ($reward) { ?> <span><?php echo $text_reward; ?></span> <?php echo $reward; ?><br /> <?php } ?> <span><?php echo $text_stock; ?></span> <?php echo $stock; ?> <br /> <span><?php echo $text_sellunit; ?></span> <?php echo $sellunit; ?></div> <?php if ($price) { ?> <div class="price"><?php echo $text_price; ?> <?php if (!$special) { ?> <?php echo $price; ?> <?php } else { ?> <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?></span> <?php } ?> На этом всё. Good luck!
×
×
  • 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.