How to: Thumbnail images in admin 2.0

All props go to the CSC team for making it so easy. Two files need to be modified.



First off, you need to modify the products.php controller for admin.



/controllers/admin/products.php - around line 840:



After the code:


<br />
if ($mode == 'manage') {<br />
	unset($_SESSION['product_ids']);<br />
	unset($_SESSION['selected_fields']);<br />
<br />
	$params = $_REQUEST;<br />
	$params['type'] = 'extended';<br />
<br />
	list($products, $search, $product_count) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'));<br />

```<br />
<br />
Insert this:<br />
<br />
```php
<br />
if (!empty($products)) {<br />
	foreach ($products as $k => $v) {<br />
		fn_gather_additional_product_data($products[$k], true);<br />
	}<br />
}<br />

```<br />
<br />
Next, edit your admin products manage view:<br />
<br />
/skins/{yer admin skin}/admin/views/products/manage.tpl<br />
<br />
You'll need to add a new column for the thumbnail in the section with all the <th> tags, and then create a corresponding <td> in the looping section with this content:<br />
<br />
```php
<br />
{include file="common_templates/image.tpl" image_width='45' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}<br />

```<br />
<br />
Obviously adjust the width to what works for you.<br />
<br />
UPDATE: For Martians flying on impulse power... a few dilithium crystals.<br />
<br />
Edit your admin products manage view:<br />
<br />
/skins/basic/admin/views/products/manage.tpl<br />
<br />
Look for this code - around line 24:<br />
<br />
```php
<br />
	{if $search.cid && $search.subcats != "Y"}<br />
	<th><a class="{$ajax_class}{if $search.sort_by == "position"} sort-link-{$search.sort_order}{/if}" href="{$c_url}&sort_by=position&sort_order={$search.sort_order}" rev="pagination_contents">{$lang.position_short}</a></th><br />
	{/if}<br />
	<th width="15%"><a class="{$ajax_class}{if $search.sort_by == "code"} sort-link-{$search.sort_order}{/if}" href="{$c_url}&sort_by=code&sort_order={$search.sort_order}" rev="pagination_contents">{$lang.code}</a></th><br />

```<br />
<br />
Insert this after:<br />
<br />
```php
<br />
	<th width="10%">Thumb</th><br />

```<br />
<br />
Then look for this code - around line 46:<br />
<br />
```php
<br />
{foreach from=$products item=product}<br />
<tr {cycle values="class=\"table-row\", "}><br />
	<td class="center"><br />
   		<input type="checkbox" name="product_ids[]" value="{$product.product_id}" class="checkbox cm-item" /></td><br />
	{if $search.cid && $search.subcats != "Y"}<br />
	<td><br />
		<input type="text" name="products_data[{$product.product_id}][position]" size="3" value="{$product.position}" class="input-text-short" /></td><br />
	{/if}<br />
<td><br />
		{$product.product_code}</td><br />

```<br />
<br />
Insert this after:<br />
<br />
```php
<br />
<td><br />
{include file="common_templates/image.tpl" image_width='40' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}<br />
</td><br />

```<br />
<br />
Then visit this page:<br />
<br />
[url]http://www.w3schools.com/html/html_tables.asp[/url]

Works perfectly - thanks for sharing!

Glen

[quote name=‘jagorny’]

You’ll need to add a new column for the thumbnail in the section with all the tags, and then create a corresponding in the looping section with this content:



{include file="common_templates/image.tpl" image_width='45' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}
Obviously adjust the width to what works for you.[/quote]



I started out reading your method thinking “WOW I’ll have this done by dinner!” Then I got to this point and my jaw dropped. I finally figured out how to finish this up wondering why did you even start a very descriptive method and then quickly become vague. Someone that just flew in from Mars would have no idea what to do at this point, and I would just recommend they follow this thread instead (http://forum.cs-cart.com/showthread.php?t=11018). Wish I had to begin with.

Perfect! Thank you!

A slight update to what has been offered here as my virgin install code was not the same. 4.0.2, so I hope im not stepping on jagorny’s toes but this worked for me.



First off, you need to modify the products.php controller for admin.



/controllers/admin/products.php - around line 480:



After this code:



```php if ($mode == ‘manage’) {

unset($_SESSION[‘product_ids’]);

unset($_SESSION[‘selected_fields’]);



$params = $_REQUEST;

$params[‘type’] = ‘extended’;



list($products, $search, $product_count) = fn_get_products($params, Registry::get(‘settings.Appearance.admin_products_per_page’));



```



Insert this:



```php if (!empty($products)) {

foreach ($products as $k => $v) {

fn_gather_additional_product_data($products[$k], true);

}

}

```



Next edit your admin products manage view:



/skins/basic/admin/views/products/manage.tpl



Look for this code - around line 21:



```php



{if $search.cid && $search.subcats != "Y"}

```

Insert this after:

```php ```

Now take note, look for this code - around line 40:

```php
{if $search.cid && $search.subcats != "Y"}

{/if}
```

Insert this after, you may have to open/start a new line between the code :


```php
```

The inserted code should like like this after inserting it in the code in lines 40-51:

```php
{if $search.cid && $search.subcats != "Y"}

{/if}



{$lang.position_short} Thumb


{include file="common_templates/image.tpl" image_width='40' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}



{include file="common_templates/image.tpl" image_width='60' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}


```

Hope it helps, failing this download and replace the 2 files attached into their respective areas /controllers/admin/products.php & /skins/basic/admin/views/products/manage.tpl

:grin:

Thumbnail-images-in admin-2.0.zip

Huh… it’s odd that your version of 2.0.4 (I think that’s what you meant) is different from mine which was an upgrade from 2.0.3… I was hoping that I would not have to do the usual process that I had to do with X, which was to compare ‘updated’ carts with the plain vanilla zips for each new release to pick up any loose change.



I would be thoroughly annoyed if that were the case - because if I have to kdiff compare anyways, the upgrade center becomes a pointless exercise.

Then I would compare the 2 to check as it would appear the two are different ? Downoad my two files and you can see…



Thanks for the initial add-on anyhow, it really helps.

How to add thumbnails to order details page ?

Anyone please?

Method suggested in first page works better then file included in attachment.


[quote name=‘Demon Templates’]A slight update to what has been offered here as my virgin install code was not the same. 4.0.2, so I hope im not stepping on jagorny’s toes but this worked for me.



First off, you need to modify the products.php controller for admin.



/controllers/admin/products.php - around line 480:



After this code:



[/QUOTE]

Can you update me on what you have found the difference is. As far as I am aware the two are idendical, as all i did was clear up confusion with the line numbers. That said, you may be correct if your version is different like jagorny quoted.


[QUOTE]Huh… it’s odd that your version of 2.0.4 (I think that’s what you meant) is different from mine which was an upgrade from 2.0.3… I was hoping that I would not have to do the usual process that I had to do with X, which was to compare ‘updated’ carts with the plain vanilla zips for each new release to pick up any loose change.



I would be thoroughly annoyed if that were the case - because if I have to kdiff compare anyways, the upgrade center becomes a pointless exercise.[/QUOTE]

Can someone shows the screenshot how it was looks on admin panel ?

[quote name=‘Demon Templates’]Then I would compare the 2 to check as it would appear the two are different ? Downoad my two files and you can see…



Thanks for the initial add-on anyhow, it really helps.[/QUOTE]



I can not get this work for 2.0.6, anything else need to change ? Thanks.

does this work with 2.0.12?

Ok, I did this a little different. Since I have already added a column for my cost, I wasn’t really able to add a new column. Since I don’t use the list price, I just changed it.



This is what I have:







I did it by:



In:



controllers/admin/products/products.php



After:


if ($mode == 'manage') {
unset($_SESSION['product_ids']);
unset($_SESSION['selected_fields']);

$params = $_REQUEST;
$params['type'] = 'extended';

list($products, $search, $product_count) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'), DESCR_SL);




I added:


if (!empty($products)) {
foreach ($products as $k => $v) {
fn_gather_additional_product_data($products[$k], true);
}
}






Then in:



skins/basic/admin/views/products/manage.tpl



I changed:


{$lang.list_price} ({$currencies.$primary_currency.symbol})



To:


Thumb



Then I changed:







To:



{include file="common_templates/image.tpl" image_width='50' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}








Now you could just add a column if you would want to. I think after reading the other instructions, you could just follow them and get the right result.



Anyways, I hope this helps.



Brandon

[quote name=‘brandonvd’]Ok, I did this a little different. Since I have already added a column for my cost, I wasn’t really able to add a new column. Since I don’t use the list price, I just changed it.



This is what I have:







I did it by:



In:



controllers/admin/products/products.php



After:


if ($mode == 'manage') {
unset($_SESSION['product_ids']);
unset($_SESSION['selected_fields']);

$params = $_REQUEST;
$params['type'] = 'extended';

list($products, $search, $product_count) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'), DESCR_SL);




I added:


if (!empty($products)) {
foreach ($products as $k => $v) {
fn_gather_additional_product_data($products[$k], true);
}
}






Then in:



skins/basic/admin/views/products/manage.tpl



I changed:


{$lang.list_price} ({$currencies.$primary_currency.symbol})



To:


Thumb



Then I changed:







To:



{include file="common_templates/image.tpl" image_width='50' obj_id=$product.product_id image=$product.main_pair.icon object_type="product"}








Now you could just add a column if you would want to. I think after reading the other instructions, you could just follow them and get the right result.



Anyways, I hope this helps.



Brandon[/QUOTE]



Its work.

Maybe do you know, how to add thumd in order details?

admin.php?dispatch=orders.details&order_id=1

In version 2.1 is a problem: admin thumb is not working for newly added products. For producst which were added before upgrade it is working. Do you have some solution?



THX

Very strange, i get directly no image avalaible when i put your code.

Yes, I can confirm that this does not work for product images added after the new update. I would really love to get this working again.

Has anyone figured this issue out in version 2.1?


[quote name=‘MimiWatch’]In version 2.1 is a problem: admin thumb is not working for newly added products. For producst which were added before upgrade it is working. Do you have some solution?



THX[/QUOTE]