На форуме 9558 тем, 76452 сообщений, 44664 участников
тема · 1 339 просмотров · 5 ответов

Как добавить в админке - order_list.twig колонку

Общие вопросы
читают: 0 участников и 1 гость
порядок
28 янв 2019 17:13#1
Oencart 3.0.2
Подскажите пожалуйста, как добавить в админке - order_list.twig колонку, которую ранее добавил в бд и хочу теперь вывести?

Допустим, clmn1
28 янв 2019 17:20#2
Написать запрос в моделе. Если колонка в таблице order то просто изменить запрос в getOrders в моделе.
Получить его в контроллере и вывести его в шаблон в том месте где и все выводится.
\admin\controller\sale\order.php
где то там
php
protected function getList() {
29 янв 2019 09:09#3
В order_list-е catalog-а, в controller-е и model-е добавил, но не помогло (
29 янв 2019 09:42#4
Пишите конкретнее, что куда, в какие файлы и что не помогло.
29 янв 2019 09:59#5
admin\controller\sale\order.php
if (!empty($order_info)) {
$data['order_id'] = $this->request->get['order_id'];
$data['store_id'] = $order_info['store_id'];
$data['store_url'] = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG;

$data['customer'] = $order_info['customer'];
$data['customer_id'] = $order_info['customer_id'];
$data['customer_group_id'] = $order_info['customer_group_id'];
$data['firstname'] = $order_info['firstname'];
$data['lastname'] = $order_info['lastname'];
$data['email'] = $order_info['email'];
$data['telephone'] = $order_info['telephone'];
$data['account_custom_field'] = $order_info['custom_field'];
// Добавил сюда
$data['my_column'] = $order_info['my_column'];

И куда только можно добавилял

admin/model/sale/order.php
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'customer' => $order_query->row['customer'],
'customer_group_id' => $order_query->row['customer_group_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'email' => $order_query->row['email'],
'telephone' => $order_query->row['telephone'],
'custom_field' => json_decode($order_query->row['custom_field'], true),
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_custom_field' => json_decode($order_query->row['payment_custom_field'], true),
'payment_method' => $order_query->row['payment_method'],
'payment_code' => $order_query->row['payment_code'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_custom_field' => json_decode($order_query->row['shipping_custom_field'], true),
'shipping_method' => $order_query->row['shipping_method'],
'shipping_code' => $order_query->row['shipping_code'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'reward' => $reward,
'order_status_id' => $order_query->row['order_status_id'],
'order_status' => $order_query->row['order_status'],
'affiliate_id' => $order_query->row['affiliate_id'],
'affiliate_firstname' => $affiliate_firstname,
'affiliate_lastname' => $affiliate_lastname,
'commission' => $order_query->row['commission'],
'language_id' => $order_query->row['language_id'],
'language_code' => $language_code,
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'ip' => $order_query->row['ip'],
'forwarded_ip' => $order_query->row['forwarded_ip'],
'user_agent' => $order_query->row['user_agent'],
'accept_language' => $order_query->row['accept_language'],
'date_added' => $order_query->row['date_added'],
'date_modified' => $order_query->row['date_modified'],
// добавил сюда
'my_column' => $order_query->row['my_column']

admin/view/template/sale/order_list.twig
{% if orders %}
{% for order in orders %}
<tr>
<td class="text-center"> {% if order.order_id in selected %}
<input type="checkbox" name="selected[]" value="{{ order.order_id }}" checked="checked" />
{% else %}
<input type="checkbox" name="selected[]" value="{{ order.order_id }}" />
{% endif %}
<input type="hidden" name="shipping_code[]" value="{{ order.shipping_code }}" /></td>
<td class="text-right">{{ order.order_id }}</td>
<td class="text-left">{{ order.customer }}</td>
<td class="text-left">{{ order.order_status }}</td>
<td class="text-right">{{ order.total }}</td>
<td class="text-left">{{ order.date_added }}</td>
<td class="text-left">{{ order.date_modified }}</td>
<td class="text-left">{{ order.my_column}}</td>

Но так и не получилось - выдает undefined index: my_column
29 янв 2019 10:43#6
В admin\controller\sale\order.php
foreach ($results as $result) {
// Добавил запрос к БД перебирая results
$my_order_info = $this->model_sale_order->getOrder($result['order_id']);
$data['orders'][] = array(
'order_id' => $result['order_id'],
'my_column' => $my_order_info['my_column'],
'customer' => $result['customer'],
'order_status' => $result['order_status'] ? $result['order_status'] : $this->language->get('text_missing'😉,
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'date_added' => date($this->language->get('date_format_short'😉, strtotime($result['date_added'])),
'date_modified' => date($this->language->get('date_format_short'😉, strtotime($result['date_modified'])),
'shipping_code' => $result['shipping_code'],
'view' => $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true),
'edit' => $this->url->link('sale/order/edit', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true)
);
И получилось - спасибо!
сообщения 1–6 из 6
Чтобы ответить, войдите или зарегистрируйтесь.

Похожие темы