Jump to content

Bigger image in BO Order details Product Line


perusi
 Share

Recommended Posts

I`m interested in showing a bigger image in the Order details page in BO. Now it currently displays the mini image, but i`m interested in showing a bigger image. I don't want to modify the mini image size and height, but to ask for another image size.

 

I know this is the code to modify in _product_line.tpl from  admin/themes/default/template/controllers/orders

<td align="center">{if isset($product.image) && $product.image->id}{$product.image_tag}{/if}</td>

I`m using PS 1.5.3.1

 

Thanks

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi friends.

First create an override

Create a file in > override\controllers\admin\AdminOrdersController.php

 

Then add this code:

class AdminOrdersController extends AdminOrdersControllerCore
{

	protected function getProducts($order)
	{
		$products = $order->getProducts();

		foreach ($products as &$product)
		{
			if ($product['image'] != null)
			{
				$name = 'product_mini_'.(int)$product['product_id'].(isset($product['product_attribute_id']) ? '_'.(int)$product['product_attribute_id'] : '').'.jpg';
				// generate image cache, only for back office
				$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');
				if (file_exists(_PS_TMP_IMG_DIR_.$name))
					$product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name);
				else
					$product['image_size'] = false;
			}
		}

		return $products;
	}
}

Look at the code when says 

$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

Change the number 45, to 100 or 150, this is the size in pixels.

 

Go to images/tmp/ then delete the product cached images, they look like "product_mini_780_1500.jpg"

 

The sistem will regenerate automaticly the images to this new size when you deletes the smallers.

 

I tested this on only orders, but this will affects to the entire backoffice, because the temp image is used in products lists an other admin pages.

 

;)

 

Share this post


Link to post
Share on other sites

  • 4 months later...
  • 6 months later...

Hello,

Thank you for the tips.

I would like to make it working on the product list of the back office on PS 1.6, to get the product_mini size to 250 px.

But the product_mini keeps a small size !!

I have deleted the tmp picture file. I have tried to override with the same code the AdminProductscontroller. I have modifyed the image size of the product_mini and regenerated the thumbnails.. I also change the size in the classes/adminTab

If you have an idea that would be great.

Thank you in advance !

Share this post


Link to post
Share on other sites

  • 1 year later...

To change product list image size, go to classes/helper/HelperList.php

 

Edit this line :

$this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);

And like before, change the 45 value for anything you want :)

Edited by KevinNash (see edit history)

Share this post


Link to post
Share on other sites

  • 1 year later...
  • 7 months later...
  • 1 month later...
  • 5 months later...
On 3/25/2014 at 9:46 PM, mantobani said:

Hi friends.

First create an override

Create a file in > override\controllers\admin\AdminOrdersController.php

 

Then add this code:

class AdminOrdersController extends AdminOrdersControllerCore
{

	protected function getProducts($order)
	{
		$products = $order->getProducts();

		foreach ($products as &$product)
		{
			if ($product['image'] != null)
			{
				$name = 'product_mini_'.(int)$product['product_id'].(isset($product['product_attribute_id']) ? '_'.(int)$product['product_attribute_id'] : '').'.jpg';
				// generate image cache, only for back office
				$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');
				if (file_exists(_PS_TMP_IMG_DIR_.$name))
					$product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name);
				else
					$product['image_size'] = false;
			}
		}

		return $products;
	}
}

Look at the code when says 

$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

Change the number 45, to 100 or 150, this is the size in pixels.

 

Go to images/tmp/ then delete the product cached images, they look like "product_mini_780_1500.jpg"

 

The sistem will regenerate automaticly the images to this new size when you deletes the smallers.

 

I tested this on only orders, but this will affects to the entire backoffice, because the temp image is used in products lists an other admin pages.

 

;)

 

hi i've tried on Prestashop 1.7.5 it show me "internal error 500" can you explain me what to change in this code for 1.7.5 version please ? thank you very much !!

Share this post


Link to post
Share on other sites

7 ore fa, eviatar dice:

hi i've tried on Prestashop 1.7.5 it show me "internal error 500" can you explain me what to change in this code for 1.7.5 version please ? thank you very much !!

On PS1.7 make a backup copy of this file:
    /controllers/admin/AdminOrdersController.php

Then find these 2 rows:

Around row 1813:

$pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$pack_item['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

Around row 2807:

$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

On both change 45 with the size you need. In my case I set them to 160.

Last step it's to delete tmp image cache... To do this locate images/tmp/ folder and delete alla the images images with name that start with "product_mini_".

Hope this helps.

Edited by DARKF3D3 (see edit history)
  • Like 2

Share this post


Link to post
Share on other sites

  • 2 weeks later...
On 1/31/2019 at 8:40 PM, DARKF3D3 said:

On PS1.7 make a backup copy of this file:
    /controllers/admin/AdminOrdersController.php

Then find these 2 rows:

Around row 1813:

$pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$pack_item['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

Around row 2807:

$product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');

On both change 45 with the size you need. In my case I set them to 160.

Last step it's to delete tmp image cache... To do this locate images/tmp/ folder and delete alla the images images with name that start with "product_mini_".

Hope this helps.

oh sorry i've forgot to say to you thank you ! it's perfect thank you very much !

Share this post


Link to post
Share on other sites

  • 5 months later...
  • 1 year later...
  • 6 months later...

I case someone it's interested to do this on PS1.7.7... you have to look at file:
/httpdocs/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php

Search for 45 and replace with the desidered value (the value it's the size of the thumbnail in pixel).

After this modify probably you should delete all the images that start with "product_mini_" into /img/tmp folder, in this way PS will regenerate them with the new size.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More