Добавление данных в инфо о заказе и при печати счета SKU, UPC и т.д. для тех кому нужно!
Так по выше указанному примеру у меня так и не получилось довести все до ума. Но нашел еще один вариант только не UPC a SKU по тому же принципу:
Затронутые файлы:
/admin/view/templates/sale/order_invoice.tpl
/admin/view/templates/sale/order_form.tpl - по тому же принципу как order_invoice.tpl
/admin/view/templates/sale/order_info.tpl - по тому же принципу как order_invoice.tpl
/admin/language/english/sale/order.php
/admin/model/sale/order.php
/admin/controller/sale/order.php
/catalog/model/checkout/order.php
-----------------------------------------------------------------------------------------------------------------------------
Первое:
В базе данных открываем раздел order_product и добавляем в нем поле sku (VARCHAR 60)
Или так:
ALTER TABLE order_product ADD sku VARCHAR(60);
-----------------------------------------------------------------------------------------------------------------------------
Начнем с
admin/view/templates/sale/order_invoice.tpl
1. Находим примерно 67 строка:
<td><b><?php echo $column_model; ?></b></td>
Дописываем над ней
<td><b><?php echo $column_sku; ?></b></td>
2. Находим примерно 79 строка:
<td><?php echo $product['model']; ?></td>
Дописываем над ней
<td align="right"><?php echo $product['sku']; ?></td>
3. Находим примерно 95 строка:
<td align="right" colspan="4"><b><?php echo $total['title']; ?>:</b></td>
Меняем количество столбцов на 5
-----------------------------------------------------------------------------------------------------------------------------
Далее переходим к файлу
admin/language/english/sale/order.php
$_['column_sku'] = 'SKU';
В место SKU указываем нужную информацию к примеру: Артикул или Поставщик
-----------------------------------------------------------------------------------------------------------------------------
Далее переходим к файлу
admin/model/sale/order.php
1. Находим примерно 84 строка
if (isset($data['order_product'])) { foreach ($data['order_product'] as $order_product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$order_product['product_id'] . "', name = '" . $this->db->escape($order_product['name']) . "', model = '" . $this->db->escape($order_product['model']) . "', quantity = '" . (int)$order_product['quantity'] . "', price = '" . (float)$order_product['price'] . "', total = '" . (float)$order_product['total'] . "', tax = '" . (float)$order_product['tax'] . "', reward = '" . (int)$order_product['reward'] . "'");
Меняем на
if (isset($data['order_product'])) { foreach ($data['order_product'] as $order_product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$order_product['product_id'] . "', name = '" . $this->db->escape($order_product['name']) . "', model = '" . $this->db->escape($order_product['model']) . "', quantity = '" . (int)$order_product['quantity'] . "', price = '" . (float)$order_product['price'] . "', total = '" . (float)$order_product['total'] . "', tax = '" . (float)$order_product['tax'] . "', reward = '" . (int)$order_product['reward'] . "', sku = '" . (float)$product['sku'] . "'");
2. Находим примерно 175 строка
foreach ($data['order_product'] as $order_product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_product_id = '" . (int)$order_product['order_product_id'] . "', order_id = '" . (int)$order_id . "', product_id = '" . (int)$order_product['product_id'] . "', name = '" . $this->db->escape($order_product['name']) . "', model = '" . $this->db->escape($order_product['model']) . "', quantity = '" . (int)$order_product['quantity'] . "', price = '" . (float)$order_product['price'] . "', total = '" . (float)$order_product['total'] . "', tax = '" . (float)$order_product['tax'] . "', reward = '" . (int)$order_product['reward'] . "'");
Меняем на
foreach ($data['order_product'] as $order_product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_product_id = '" . (int)$order_product['order_product_id'] . "', order_id = '" . (int)$order_id . "', product_id = '" . (int)$order_product['product_id'] . "', name = '" . $this->db->escape($order_product['name']) . "', model = '" . $this->db->escape($order_product['model']) . "', quantity = '" . (int)$order_product['quantity'] . "', price = '" . (float)$order_product['price'] . "', total = '" . (float)$order_product['total'] . "', tax = '" . (float)$order_product['tax'] . "', reward = '" . (int)$order_product['reward'] . "' , sku = '" . (float)$product['sku'] . "'");
3. Находим примерно 480 строка
public function getOrderProducts($order_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'"); return $query->rows;
}
Меняем на
public function getOrderProducts($order_id) { $query = $this->db->query("SELECT a.*, b.sku FROM " . DB_PREFIX . "order_product a LEFT JOIN " . DB_PREFIX . "product b ON a.product_id = b.product_id WHERE order_id = '" . (int)$order_id . "'"); return $query->rows; }
-----------------------------------------------------------------------------------------------------------------------------
Далее переходим к файлу
admin/controller/sale/order.php
1. Находим примерно 1090 строка
'reward' => $order_product['reward'],
Дописываем над ней
'sku' => $order_product['sku']
2. Находим примерно 2285 строка
$this->data['column_model'] = $this->language->get('column_model');
Дописываем над ней
$this->data['column_sku'] = $this->language->get('column_sku');
3. Находим примерно 2425 строка
'option' => $option_data,
Дописываем под ней
'sku' => $product['sku'],
-----------------------------------------------------------------------------------------------------------------------------
Далее переходим к файлу
catalog/model/checkout/order.php
1. Находим примерно 480 строка
foreach ($data['products'] as $product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "''");
Меняем на
foreach ($data['products'] as $product) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "', sku = '" . (float)$product['sku'] . "'");
ВСЕ, естественно все тронутые файлы сохраняем, не забываем про UTF8, проверяем работоспособность!
-----------------------------------------------------------------------------------------------------------------------------
Источник решения на EN
-----------------------------------------------------------------------------------------------------------------------------
Пример то что получилось
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------