Anyone have experience in this realm? I can code PHP, I just need to be able to find the source of the invoice and can probably hastily add what I'd like.

In admin/controller/sale/order.php file,
Find:
Code: Select all
$this->data['column_model'] = $this->language->get('column_model');
Code: Select all
$this->data['column_category'] = $this->language->get('column_category');
Code: Select all
$this->data['order_products'][]
Code: Select all
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id']);
if ($category_info) {
$this->data['category_info'] = array();
foreach ($category_info as $cat_info) {
$this->data['category_info'][] = array(
'product_id' => (int)$cat_info['product_id'],
'name' => $cat_info['name'],
);
}
}
Find:
Code: Select all
public function getProductsByCategoryId($category_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id = '" . (int)$category_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
Code: Select all
public function getCategoriesByProduct($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (c.category_id = p2c.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
In admin/view/template/sale/order_form.tpl file,
find:
Code: Select all
<td class="left"><?php echo $column_model; ?></td>
Code: Select all
<td class="left"><?php echo $column_category; ?></td>
Code: Select all
<td class="left"><?php echo $order_product['name']; ?><br />
Code: Select all
<?php foreach ($category_info as $cat_info) { ?>
<?php if ((int)$order_product['product_id'] == (int)$cat_info['product_id']) { ?>
<td class="left"><?php echo $cat_info['name']; ?><br />
<?php } ?>
<?php } ?>
find:
Code: Select all
$_['column_model'] = 'Model';
Code: Select all
$_['column_category'] = 'Categories';
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I too am after something like this were I can see the category in an extra column of the sales >> orders >> edit page but nothing showing?
I have the extra column displaying but nothing shows in the category box of each product?
Here's what I have done so far...
In admin/controller/sale/order.php file, I have added...
Code: Select all
$this->data['column_category'] = $this->language->get('column_category');
Code: Select all
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id']);
if ($category_info) {
$this->data['category_info'] = array();
foreach ($category_info as $cat_info) {
$this->data['category_info'][] = array(
'product_id' => (int)$cat_info['product_id'],
'name' => $cat_info['name'],
);
}
}
Code: Select all
public function getCategoriesByProduct($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (c.category_id = p2c.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
Code: Select all
<td class="left"><?php echo $column_category; ?></td>
Code: Select all
<?php foreach ($category_info as $cat_info) { ?>
<?php if ((int)$order_product['product_id'] == (int)$cat_info['product_id']) { ?>
<td class="left"><?php echo $cat_info['name']; ?><br />
<?php } ?>
<?php } ?>
Code: Select all
$_['column_category'] = 'Categories';
thanks for any help

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com
Find:
Code: Select all
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id']);
Code: Select all
if ($order_info) {
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id'], $order_info['store_id']);
} else {
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id'], $this->config->get('config_store_id'));
}
Code: Select all
public function getCategoriesByProduct($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (c.category_id = p2c.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
Code: Select all
public function getCategoriesByProduct($product_id, $store_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.category_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN `" . DB_PREFIX . "category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' AND c2s.`store_id` = '" . (int)$store_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester

I have since edited the exact named files being...
admin/controller/sale/order.php
admin/model/catalog/product.php
admin/view/template/sale/order_form.tpl
admin/language/english/sale/order.php
but no column shows or nothing & from the changes that have been made to OC1.5.x, I think I should be editing the admin/view/template/sale/order_info.tpl instead of the .../sale/order_form.tpl but I have tried editing the order_info.tpl & I now have the column showing but with no categories
Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com
If I put this line of code in mysql database...
Code: Select all
SELECT cd.name FROM category c LEFT JOIN category_description cd ON (cd.category_id = c.category_id) LEFT JOIN product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN `category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE p2c.product_id =47543
Code: Select all
SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.category_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN `" . DB_PREFIX . "category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com

Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thanks again for the help & the error log is showing the 2 following...straightlight wrote:Enable the error logs from your OpenCart store settings. This should display the main reason why the query may fail to load from OpenCart under that store. Since today, I have added the store ID into the query for this reason, specifically.
PHP Notice: Undefined variable: category_info in order_info.tpl
PHP Warning: Invalid argument supplied for foreach() in order_info.tpl
Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com
To fix this, in your template, replace:
Code: Select all
<?php foreach ($category_info as $cat_info) { ?>
<?php if ((int)$order_product['product_id'] == (int)$cat_info['product_id']) { ?>
<td class="left"><?php echo $cat_info['name']; ?><br />
<?php } ?>
<?php } ?>
Code: Select all
<?php if ($category_info) { ?>
<?php foreach ($category_info as $cat_info) { ?>
<?php if ((int)$order_product['product_id'] == (int)$cat_info['product_id']) { ?>
<td class="left"><?php echo $cat_info['name']; ?><br />
<?php } ?>
<?php } ?>
<?php } ?>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester

I have tried what you said & now the error log just shoes the one warning...
PHP Notice: Undefined variable: category_info in order_info.tpl
Is it anything to do with me making the changes in the order_info.tpl instead of the order_form.tpl because if I make changes in the order_form.tpl, nothing is shown, not even the extra column?
regards
h
Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com
straightlight wrote:Enable the error logs from your OpenCart store settings. This should display the main reason why the query may fail to load from OpenCart under that store. Since today, I have added the store ID into the query for this reason, specifically.
thanks for the reply but any chance of an idea as to the coding to use?rewq111 wrote:imply by reversing psychology, when we can't get a product by categories, we have to get a category by products.
In admin/controller/sale/order.php file,
regards
Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com
Notice: Error: Unknown column 'pd.name' in 'order clause'
Error No: 1054
SELECT * FROM kbb_category c LEFT JOIN kbb_category_description cd ON (cd.category_id = c.category_id) LEFT JOIN kbb_product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN `kbb_category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE cd.language_id = '1' AND p2c.product_id = '161' AND c2s.`store_id` = '0' ORDER BY pd.name ASC in /var/zpanel/hostdata/zadmin/public_html/*******/system/database/mysql.php on line 50
Should mension im using version 1.5.5.1 with mysql 5.1 and php 5.3.3
Code: Select all
public function getCategoriesByProduct($product_id, $store_id) {
$query = $this->db->query("SELECT *, `cd`.`name` AS `name` FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.category_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (pd.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (p.product_id = pd.product_id) LEFT JOIN `" . DB_PREFIX . "category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' AND c2s.`store_id` = '" . (int)$store_id . "' ORDER BY pd.name ASC");
return $query->rows;
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Neither. This modification would be for the admin/model/sale/order.php file.alishjee wrote:which file to be edit order_info or order form?
Can you rearrange your post again? Thanks
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
Undefined variable: category_info in C:\wamp\www\testing\vqmod\vqcache\vq2-admin_view_template_sale_order_invoice.tpl on line 96
Users browsing this forum: No registered users and 6 guests