( I have also posted the instructions below in the contributions of the main site, as a zipped text file downloadable here:
http://www.opencart.com/index.php?route ... tion_id=95 )
This upgrade for the admin makes it possible to copy a product, including all settings and options, with two button clicks. To implement this upgrade all you need to do is make these 6 small changes:
1.In system/engine/router.php, change line 4 from:
protected $method;
to:
public $method;
2.In admin/controller/catalog/product.php, change lines 232-235 from:
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url)
);
to:
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url),
'text2' => $this->language->get('text_copy'),
'href2' => $this->url->https('catalog/product/insert&product_id=' . $result['product_id'] . $url)
);
3.In the same file, after line 344:
private function getForm() {
add this line:
global $action;
4.In the same file, change line 442 from:
if (!isset($this->request->get['product_id'])) {
to:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
5.In the file admin/view/template/catalog/product_list.tpl, after line 135:
[ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
add this line:
[ <a href="<?php echo $action['href2']; ?>"><?php echo $action['text2']; ?></a> ]
6.In the file admin/language/english/english.php, after line 26:
$_['text_edit'] = 'Edit';
add this line:
$_['text_copy'] = 'Copy';
That's it! Now when you go to Catalogue/Product in the admin, you will see next to each product not only an Edit link, but also a Copy link. To copy a product just click on the Copy link, then make any changes on any of the tabs if you wish, and click Save.
http://www.opencart.com/index.php?route ... tion_id=95 )
This upgrade for the admin makes it possible to copy a product, including all settings and options, with two button clicks. To implement this upgrade all you need to do is make these 6 small changes:
1.In system/engine/router.php, change line 4 from:
protected $method;
to:
public $method;
2.In admin/controller/catalog/product.php, change lines 232-235 from:
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url)
);
to:
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url),
'text2' => $this->language->get('text_copy'),
'href2' => $this->url->https('catalog/product/insert&product_id=' . $result['product_id'] . $url)
);
3.In the same file, after line 344:
private function getForm() {
add this line:
global $action;
4.In the same file, change line 442 from:
if (!isset($this->request->get['product_id'])) {
to:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
5.In the file admin/view/template/catalog/product_list.tpl, after line 135:
[ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
add this line:
[ <a href="<?php echo $action['href2']; ?>"><?php echo $action['text2']; ?></a> ]
6.In the file admin/language/english/english.php, after line 26:
$_['text_edit'] = 'Edit';
add this line:
$_['text_copy'] = 'Copy';
That's it! Now when you go to Catalogue/Product in the admin, you will see next to each product not only an Edit link, but also a Copy link. To copy a product just click on the Copy link, then make any changes on any of the tabs if you wish, and click Save.
I haven't tried this, so maybe I'm wrong.. But looking at this part of the code:
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url),
'text2' => $this->language->get('text_copy'),
'href2' => $this->url->https('catalog/product/insert&product_id=' . $result['product_id'] . $url)
);
it looks like Copy would duplicate the existing product_id as well. Wouldn't the database reject that since product_id is supposed to be unique?
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->https('catalog/product/update&product_id=' . $result['product_id'] . $url),
'text2' => $this->language->get('text_copy'),
'href2' => $this->url->https('catalog/product/insert&product_id=' . $result['product_id'] . $url)
);
it looks like Copy would duplicate the existing product_id as well. Wouldn't the database reject that since product_id is supposed to be unique?
Hi, I can assure you it works, and I would not have posted this without testing it first :-)
Including the id within the copy link makes sure all the data of the existing product with the old id are first loaded in the form. But then the trick is mainly here:
4.In the same file, change line 442 from:
if (!isset($this->request->get['product_id'])) {
to:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
If you look in admin/controller/catalog/product.php at the code which follows it is more clear what this changes:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
$this->data['action'] = $this->url->https('catalog/product/insert' . $url);
} else {
$this->data['action'] = $this->url->https('catalog/product/update&product_id=' . $this->request->get['product_id'] . $url);
}
You see, the "insert" part of the URL prompts the system to proceed with a product insert instead of a product update when you click on save. And doing the insert into the database automatically generates a new fresh id!
Henry
Including the id within the copy link makes sure all the data of the existing product with the old id are first loaded in the form. But then the trick is mainly here:
4.In the same file, change line 442 from:
if (!isset($this->request->get['product_id'])) {
to:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
If you look in admin/controller/catalog/product.php at the code which follows it is more clear what this changes:
if (!isset($this->request->get['product_id']) || $action->method=="insert") {
$this->data['action'] = $this->url->https('catalog/product/insert' . $url);
} else {
$this->data['action'] = $this->url->https('catalog/product/update&product_id=' . $this->request->get['product_id'] . $url);
}
You see, the "insert" part of the URL prompts the system to proceed with a product insert instead of a product update when you click on save. And doing the insert into the database automatically generates a new fresh id!
Henry
If you look in the contributions section I'm sure the bottom download works for 1.3.2 and 1.3.4.
www.opencartstore.com
Get OpenCart Templates and OpenCart Modules.
how did you do it for 1.4.0 ?
because, i did it also, and copy works, but now, when i click edit, it says, page not found.
can you help?
because, i did it also, and copy works, but now, when i click edit, it says, page not found.

can you help?
Logohunt.Net, Get Amazing custom logo designs for your business in just a few Hours! Start a online logo design contest for only $29 and watch designer logos roll in the same day!
ok I'm sorry, I didn't see you had posted here first.stefke1974 wrote:how did you do it for 1.4.0 ?
because, i did it also, and copy works, but now, when i click edit, it says, page not found.
![]()
can you help?
well, when you are viewing your products and decide which to copy, click copy, then when the page changes, you are looking at your copied product. so make your changes and then click save, and you'll be returned to your product list which will include your newest product. you can click edit on any of them and make more changes.
now the first time I did it I didn't realize right away I was looking at the copy, I expected the copy to show up on the list. so let's say you click copy and you think it's the original product and you don't click save or you hit the back button then that may cause your copy to be messed up.
if that's not the case then I have to assume you made some mistake in installation.
Use something like Notepad ++ to edit your php files.
Also make sure you are using the version for 1.4.0, you have to scroll all the way down the contribution page.
Guys,
thanks to artlife, i found the problem.
my mistake.
i deleted the line public function update() { in product.php.
it works fine now.
thanks artlife. you saved me
thanks to artlife, i found the problem.
my mistake.
i deleted the line public function update() { in product.php.
it works fine now.
thanks artlife. you saved me

Logohunt.Net, Get Amazing custom logo designs for your business in just a few Hours! Start a online logo design contest for only $29 and watch designer logos roll in the same day!
Who is online
Users browsing this forum: Amazon [Bot] and 2 guests