Articles Menu

Article Search

Latest Articles
There are lots of extensions on the opencart extension directory to bulk modify product prices. However if you only have to do this once in a while or you are looking for a quick free way to do thi.. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
Having affiliates is a great way to boost your sales, so this article will help you atract more affiliates to your website by displaying somewhere on the product page how much an affiliate wil make.. Read More
Many people ask about the setting on how many products are beeing displayed per row in opencart modules or category listings. Well there is no such setting, I mean there might be in some custom the.. Read More
All Articles

How to add a view product link in opencart admin product list

Sometimes after you insert or edit a product in opencart admin you would like to see the result in frontend. Currently to do that you would have to go to the opencart frontend and then navigate trough the path to that product.

The below trick will show you how to add a view product in store frontend  link in the opencart admin product listing. And in the case you use multistore , this will ad a view link for each store the product belongs to.

First edit the file admin/controller/catalog/product.php and find the line:

$this->data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');

And below it add the code: 

$this->data['store'] = HTTP_CATALOG;
$this->data['stores'] = array();


$results = $this->model_setting_store->getStores();

foreach ($results as $result) {
$this->data['stores'][] = array(
'name' => $result['name'],
'id' => $result['store_id'],
'href' => $result['url']

Now edit the file admin/view/template/catalog/product_list.tpl and find the code:

<?php foreach ($product['action'] as $action) { ?>
[ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
<?php } ?>

Below it add the code: 

$product_store = $this->model_catalog_product->getProductStores($product['product_id']);
<?php if (in_array(0, $product_store)) { ?>
[<a onClick="'<?php echo $store . 'index.php?route=product/product&product_id=' . $product['product_id']; ?>');">View in Main store</a>]<br />
<?php } ?>
<?php foreach ($stores as $storel) { ?>
<?php if (in_array($storel['id'], $product_store)) { ?>
[<a onClick="'<?php echo $storel['href'] . 'index.php?route=product/product&product_id=' . $product['product_id']; ?>');">View in <?php echo $storel['name']; ?></a>]<br />
<?php } ?>
<?php } ?>

That is all.

Posted by Flo

7 Comments To "How to add a view product link in opencart admin product list"

Jorge Augusto On 22 Dec 2013
Great post. Thanks for this code Reply to this comment
dragoncorp On 31 Oct 2013
Thanks a lot, very useful code!!!!!! Reply to this comment
@iSaulius On 24 Aug 2013
A lot Thanks !!!!!!!!!!!!!!!! Reply to this comment
Erman On 18 Mar 2013
Great post. Thank you Flo. You saved my time.. Reply to this comment
David On 04 Nov 2012
Hello Flo, how can update code for products, which are not allowed to show on the shop, but you want to preview anyway? For example new products in preparation ... When you click on the link View in Main store and product is not allowed to show, you get the info about not found the product. David Reply to this comment
Flo On 12 Apr 2012
You are right. Sorry, i will update the post. Reply to this comment
Carlos Alberto On 12 Apr 2012
Now edit the file admin/view/template/catalog/product_form.tpl and find the code: <?php foreach ($product['action'] as $action) { ?> [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ] <?php } ?> This not in product_form.tpl, is in product_list.tpl Reply to this comment

Write a comment

Your Name:

Enter the code in the box below:

Your Comment:
Note: HTML is not translated!
Opencart templates © 2014