Adding product thumbs in Admin section

Hello,



I’m trying to add image thumbnails in the admin section (see screenshot), it’s easier when you have a long list of product to identify them with images instead of the product name.



I played with the code a little bit in \SKIN\admin\products_pages\products.tpl but I am not sure I am linking to the correct image path. Can somebody help?




```php




[COLOR="Red"]{*ADDED IMAGE*}
{$product.$field.alt}

{*ADDED IMAGE END*}[/COLOR]

{if $smarty.get.cid && $smarty.get.subcats!='Y'}


{/if}
```

[quote name=‘gugga7’]I’m trying to add image thumbnails in the admin section (see screenshot)[/QUOTE]

where’s the screenshot?

Sorry here is the image attached.

Picture 35.jpg

see if you can copy the image code from product_update.tpl, I’m guessing something like the below code is closer to what you are looking for, let us know if this works, if not we’ll figure it out.


{include file="common_templates/image.tpl" show_detailed_link="N" obj_id=$product.product_id images=$product.main_pair object_type="product"}

That was the first thing I tried, it didn’t work.

I think the reason that code doesn’t work is that the two pages pull different information from the database.



You will most likely have to add an extra query to the database before hand.

Unfortunately, I’m not an SQL guy, if somebody has a clue as to how to achieve this, please don’t hesitate :slight_smile:



This could be useful for all members who want to have a visual of their product other than the product name. Especially when the product list is long…

Here’s a solution I found recently.



In “skins/ADMIN_SKIN/admin/products_pages/products.tpl”



ADD PART IN RED


```php



[COLOR=Red] [/COLOR]

{if $smarty.get.cid && $smarty.get.subcats!='Y'}

{/if}







```AND HERE

```php

[COLOR=Red] [/COLOR]

{if $smarty.get.cid && $smarty.get.subcats!='Y'}
Image
{$lang.position_short}{if $sort_by == 'position'}{$sort_sign}{/if} {$lang.code}{if $sort_by == 'code'}{$sort_sign}{/if} {$lang.product}{if $sort_by == 'product'}{$sort_sign}{/if} {$lang.price} ({$currencies.$primary_currency.symbol}){if $sort_by == 'price'}{$sort_sign}{/if} {$lang.list_price} ({$currencies.$primary_currency.symbol}){if $sort_by == 'list_price'}{$sort_sign}{/if} {$lang.quantity}{if $sort_by == 'amount'}{$sort_sign}{/if} {$lang.avail}{if $sort_by == 'avail'}{$sort_sign}{/if}

{assign var="prod_id" value=$product.product_id}
{php}
$product_id = $this->get_template_vars('prod_id');
$image_id = db_get_row("SELECT image_id FROM cscart_product_images_links WHERE type='M' AND product_id=$product_id");
$image_id = $image_id['image_id'];
if($image_id == null) {
$image_path = "no_image.gif";
} else {
$image_path = db_get_row("SELECT image_path FROM cscart_product_images WHERE image_id=$image_id");
$image_path = $image_path['image_path'];
if($image_path == null) {
$image_path = "no_image.gif";
}
}
[/COLOR][COLOR=Red] $this->assign('image_path',$image_path);
[/COLOR][COLOR=Red] {/php}[/COLOR]
[COLOR=Red]


```

Sweet!



I’ve been wanting to do this for a LONG time. I used some of MDE’s other code he helped me with to add this, if there’s no image associated with the product. You have to place an image “no_image.gif” in your root images directory for it to work. I’ve made mine an icon that’s easy to see.



Thanks MDE!



(Add in red)






{assign var="prod_id" value=$product.product_id}
{php}
$product_id = $this->get_template_vars('prod_id');
$image_id = $database->select(array('image_id'),'cscart_product_images_links',"type='M' AND product_id=$product_id");
$image_id = $image_id[0][0];
$image_path = $database->select(array('image_path'),'cscart_product_images',"image_id=$image_id");
$image_path = $image_path[0][0];

[COLOR="Red"]if($image_path == null) {
$image_path = "no_image.gif";
}[/COLOR]

echo "\"\"";
{/php}



{if $smarty.get.cid && $smarty.get.subcats!='Y'}

And if you want images in your order_details page, try this:



In “skins/ADMIN_SKIN/admin/orders_pages/order_details.tpl”



ADD



{$lang.sku}
[COLOR=Red] Image[/COLOR]
AND ADD



{$oi.product_code}
[COLOR=Red]
{assign var="prod_id" value=$oi.product_id}
{php}
$product_id = $this->get_template_vars('prod_id');
$image_id = db_get_row("SELECT image_id FROM cscart_product_images_links WHERE type='M' AND product_id=$product_id");
$image_id = $image_id['image_id'];
if($image_id == null) {
$image_path = "no_image.gif";
} else {
$image_path = db_get_row("SELECT image_path FROM cscart_product_images WHERE image_id=$image_id");
$image_path = $image_path['image_path'];
if($image_path == null) {
$image_path = "no_image.gif";
}
}
[/COLOR][COLOR=Red] $this->assign('image_path',$image_path);[/COLOR]
[COLOR=Red] {/php}[/COLOR][COLOR=Red]
[/COLOR][COLOR=Red]
[/COLOR]

And if you want images in your invoice page, try this:



In “skins/CLIENT_SKIN/mail/orders_pages/invoice.tpl”



ADD



{$lang.sku}
[COLOR=Red] Image[/COLOR]
AND ADD



{$oi.product_code|default:" "}
[COLOR=Red]
{assign var="prod_id" value=$oi.product_id}
{php}
$product_id = $this->get_template_vars('prod_id');
$image_id = db_get_row("SELECT image_id FROM cscart_product_images_links WHERE type='M' AND product_id=$product_id");
$image_id = $image_id['image_id'];
if($image_id == null) {
$image_path = "no_image.gif";
} else {
$image_path = db_get_row("SELECT image_path FROM cscart_product_images WHERE image_id=$image_id");
$image_path = $image_path['image_path'];
if($image_path == null) {
$image_path = "no_image.gif";
}
}
[/COLOR][COLOR=Red] $this->assign('image_path',$image_path);
[/COLOR][COLOR=Red] {/php}
[/COLOR][COLOR=Red] [/COLOR][COLOR=Red]
[/COLOR]

[quote name=‘mdekok3000’]


  1. At the end of config.php, add this:[/QUOTE]



    Is it right - the config.php file in the root? I added the code which you indicated and site was unaccessible.

Did you place it before the “?>”? Someone else put it after and said the same thing.

[quote name=‘mdekok3000’]Did you place it before the “?>”? Someone else put it after and said the same thing.[/QUOTE]



Thanks you, Matt, for the replay. Yes, I placed the code before “?>” and browser gives me error message



Parse error: parse error, expecting T_OLD_FUNCTION' or T_FUNCTION’ or T_VAR' or ‘}’’



pointing out on the string



public $db = false;

Try these new instructions. (See Posts 8, 10, and 11)



I finally got CS-Cart’s built in database function working for this. Forgot that the result is an array where the key is the field name.

You are genius! It works!



Thank you, Matt. I made some donation

Very nice addition. Thanks

Wow, this is very great mod!!! Thank you

An issue has been discovered and fixed. Those that have it working may or may not discover this issue. I would still recommend making the change.



If for some reason this change messes something up, simply use the first version.

Under FF everything looks ok, but on IE pictures are huge.