Post by felizone » Wed Dec 07, 2011 1:28 am

Dear All,

I would appreciated if anyone can let me know what file, and stpes to add SKU code to be displayed on PRODUCT INVOICE.

I have tried and added SKY CODE perfectly to product page, however, i got error "Notice: Undefined index: sku in C:\AppServ\www\upload\admin\controller\sale\order.php on line 1327".

The column SKU displayed OK. THE value SKU CODE does not.

Please let me know if you have any idea what i should do.

Cheers,
Felizone ;D

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by uksitebuilder » Wed Dec 07, 2011 1:33 am

Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:

order_id
product_id
name
model
quantity
price
total
tax

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by felizone » Wed Dec 07, 2011 9:31 am

uksitebuilder wrote:Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:

order_id
product_id
name
model
quantity
price
total
tax
Thanks for your reply.
I just want to add the SKU to invoice only , NOT other places.
Any simple coding?

Thanks. ;D

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by felizone » Wed Dec 07, 2011 10:13 am

felizone wrote:
uksitebuilder wrote:Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:

order_id
product_id
name
model
quantity
price
total
tax
Thanks for your reply.
I just want to add the SKU to invoice only , NOT other places.
Any simple coding?

Thanks. ;D
I see the SKU is not be stored same place as Product code, it only stored in "PRODUCT" table.
How can i get it?

"ECHO" from product table???????

Thanks.

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by Teyno » Wed Dec 07, 2011 10:21 am

Never worked with PHP before, but I looked into the architecture and this isn't hard to do.

Not taking any responsibility and just giving the basics.

in admin/model/sale/order.php find

Code: Select all

public function getOrderProducts($order_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
		
		return $query->rows;
	}
You need to edit that query with a JOIN to get the SKU from another table.

Then you have to add the sku to the product array

in admin/controller/sale/order.php find

Code: Select all

$product_data[] = array(
						'name'     => $product['name'],
						'model'    => $product['model'],
						'option'   => $option_data,
						'quantity' => $product['quantity'],
						'price'    => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
						'total'    => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])
					);
There you insert

Code: Select all

'sku'    => $product['sku'],
Also in the invoice() function on same page you have to insert something like
$this->data['column_sku''] = $this->language->get('sku'); or just
$this->data['column_sku'] = 'SKU'; if you dont want to edit the language files, this is for the column header

Now you can use the variables $column_sku and $product['sku'] in your template

Please have in mind I am not a PHP developer but this is how I would TRY it :D, back-ups are advised.

New member

Posts

Joined
Tue Dec 06, 2011 5:37 pm

Post by felizone » Wed Dec 07, 2011 10:23 am

Apprecaited Teyno.
I will give a try.

I will post if it works for me.

Thank you.

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by Teyno » Wed Dec 07, 2011 10:45 am

Got you the query, tested in in phpmyadmin and works OK

Code: Select all

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;
   }
Let me know if it works :) and also try if it works when a product has no SKU.. thats why I didn't do an INNER JOIN.

New member

Posts

Joined
Tue Dec 06, 2011 5:37 pm

Post by nosecret » Wed Dec 07, 2011 10:58 am

I am release extension SKU in INVOICE, perhaps that suitable for you. Please check link below:
http://www.opencart.com/index.php?route ... on_id=2646

Active Member

Posts

Joined
Tue Dec 28, 2010 12:28 pm

Post by felizone » Wed Dec 07, 2011 11:01 am

Teyno wrote:Got you the query, tested in in phpmyadmin and works OK

Code: Select all

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;
   }
Let me know if it works :) and also try if it works when a product has no SKU.. thats why I didn't do an INNER JOIN.
Oops.... :laugh: It works perfect.
Teyno, YOU ARE MY SUPER STAR.

Appreciated your time.

Have a nice day. Cheers... O0

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by felizone » Wed Dec 07, 2011 11:05 am

It shows nothing there if product has no SKU.
Will this a bug? I think no...

It works perfect for me.

Thank you. Teyno

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by felizone » Wed Dec 07, 2011 11:05 am

nosecret wrote:I am release extension SKU in INVOICE, perhaps that suitable for you. Please check link below:
http://www.opencart.com/index.php?route ... on_id=2646
Thanks, but it's not suitable for me to show SKU all around.

Thanks.

New member

Posts

Joined
Thu Apr 08, 2010 3:28 pm

Post by Teyno » Wed Dec 07, 2011 5:40 pm

felizone wrote:It shows nothing there if product has no SKU.
Will this a bug? I think no...

It works perfect for me.

Thank you. Teyno
Your very welcome.. :)

New member

Posts

Joined
Tue Dec 06, 2011 5:37 pm

Post by afonte » Mon Feb 20, 2012 10:47 pm

I need to get my SKU on my invoices as well but I want to make sure I am understanding these instructions correctly before I start to fiddle.

1. I would edit the files as stated above.
2. Then run the query on my database thru PHPmyAdmin.

Let me know if I got this right so I can give it a go. Thanks! :)

New member

Posts

Joined
Thu Feb 09, 2012 10:50 pm

Post by H2O » Thu Mar 29, 2012 7:16 am

A HOW-To has been created to add SKU numbers to the Invoice. It was done to version 1.5.2.1.

It can be found here:
http://forum.opencart.com/viewtopic.php?f=121&t=57412

A good site for e-commerce advice.


H2O
New member

Posts

Joined
Wed Feb 29, 2012 7:36 am

Post by bedo02 » Sun Jan 12, 2014 1:09 am

Hi Teyno,

perfect :) works like a charm. I have created an very complicated way see post http://forum.opencart.com/viewtopic.php ... 878#p90940

I am no SQL expert, I was thinking about a join function as well, just did not know how to write it, you did it. Big thanks!
I am now migrating from 147 to 156 so had to rewrite all the functions, this saves me a lots of time and it is also future proof! :)

Here my vqmod file to add skus on invoice.

Code: Select all

<modification>
	<id>SKUs on Invoice</id>
	<version>1.0.0</version>
	<vqmver>1.0.8</vqmver>
	<author>Bedo & Teyno :)</author>

<file name="admin/model/sale/order.php">      
        
		<operation>
			<search position="replace"><![CDATA[$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");]]></search>
			<add><![CDATA[
            $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 . "'");
          ]]></add>
		</operation>
        
	</file>
    
   	<file name="admin/controller/sale/order.php">
     
		<operation>
			<search position="after"><![CDATA['model'    => $product['model'],]]></search>
			<add><![CDATA[
            'sku'      => $product['sku'],
          ]]></add>
		</operation>
 	</file>       
<file name="admin/view/template/sale/order_invoice.tpl">

        <operation>
			<search position="before"><![CDATA[<td><b><?php echo $column_product; ?></b></td>]]></search>
			<add><![CDATA[
            <td><b><?php echo 'SKU'; ?></b></td>
          ]]></add>
		</operation>

<operation>
			<search position="before"><![CDATA[<td><?php echo $product['name']; ?>]]></search>
			<add><![CDATA[
            <td><?php echo $product['sku']; ?></td>
          ]]></add>
		</operation>

       <operation>
			<search position="replace"><![CDATA[<td align="right" colspan="4"><b><?php echo $total['title']; ?>:</b></td>]]></search>
			<add><![CDATA[
            <td align="right" colspan="5"><b><?php echo $total['title']; ?>:</b></td>
          ]]></add>
		</operation>

	</file>

 </modification>
just save this code as .xml and upload to vqmod/xml folder
... yes for this you need to install vqmod, but better then modify base files...
-- or just search for the above statements in <search></search> and add / replace as stated in the code..

@ Teyno - thanks Mister O0

using oc 1.5.6


Newbie

Posts

Joined
Mon Oct 26, 2009 9:43 pm

Post by andyblackett » Wed Jan 29, 2014 4:01 am

Hi there,

I'd love to have this functionality on our admin order invoice page but when I upload the xml file detailed above I just get an error "Warning: VQMod script XML syntax is invalid! Please contact the author for support." and nothing happens.

Are you able to advise on what might be wrong?

Best wishes
Andy

Newbie

Posts

Joined
Mon Dec 31, 2012 7:54 am

Post by nvedia » Wed Jan 29, 2014 9:26 am

Can you please post your entire XML here?

Donate here to show support if you think I have helped you today!

Opencart Documentation


User avatar
Active Member

Posts

Joined
Sun May 22, 2011 12:54 pm

Post by hamidg84 » Wed Feb 12, 2014 7:17 am

Hi

It says Warning: VQMod script XML syntax is invalid!

Can you please help?

Active Member

Posts

Joined
Wed Feb 29, 2012 6:18 am

Post by hamidg84 » Thu Feb 20, 2014 9:34 am

Anyone please??

Active Member

Posts

Joined
Wed Feb 29, 2012 6:18 am

Post by rajkumar2086 » Thu Jun 26, 2014 10:06 am

Confirming that the mods tutored by teyno works perfect on 1.5.6.4
Im uploading my files to help others like myself who dont know a zilch on coding but would like to have sku
just upload to your home directory and unzip, the files will go sit in their respective places...
How it works
SKU returned for items with SKU
Blank SKU column for items without SKU

disclaimer - you are responsible for your actions. Kindly back up your admin folder before doing this ... it worked flawless for me but I can no way assure the same for you....(Yet I am sure it will)

Attachments

All files with the mods indicated by teyno works for me on 1.5.6.4 on a heavily customised theme


Newbie

Posts

Joined
Mon Jun 23, 2014 2:29 pm
Who is online

Users browsing this forum: Ahrefs [Bot] and 147 guests