Jump to content

Images not listed in the product settings in backend (Presatshop 1.6.1.11)


DpHermes

Recommended Posts

Hello people.

 

I have quite an issue here...

After I migrated my website from one server to another, images are not listed in my products.

I'm not talking about "I don't see my thumbnails" or I have a question mark. Noooo!!! Images are simply not listed at all in my products settings.

 

On the frontend : everything works just fine. No problem with products, no problem with images.

Back end :

when I just go to catalogue > products : I have the thumbnails and so on. Seems to work fine (see screenshot01.png)

Then, I click on a product to manage images.

In the product settings, i click on "images", the back office knows I have 2 images (e.g.) but doesn't list any... (see screenshot02.png)

 

Did someone have something like that ? I have to acknowledge : seems like a weird stuff to me, and I don't know what to do... :

  • I cleared the cache
  • Enabled/disabled the cache
  • Regenerated images
  • Cleared the img/tmp file
  • Seems I have all my database tables...

 

People... Help ! I'm lost. :)

post-792119-0-05085700-1486052053_thumb.png

post-792119-0-19790600-1486052061_thumb.png

Link to comment
Share on other sites

 

Have you tried adding a new product?

 

Doing this will establish whether:

 

  1. You can upload product images to the new product

     

  2. The new product's images are displayed properly in the back end.

 

 

Yes, sorry, I forgot to mention it...

When I add a new product : absolutely no problem.

Even more... When I add an image to an existing product, the new image is showing up, but not the others.

(e.g : for an "old" product for which I have 2 images, none is showing. When I add a new image. The admin says I have 3 images, but only the new uploaded is showing up)

Drive me a bit crazy.... Ah ah

Link to comment
Share on other sites

On the assumption you're using v1.6:

 

In your back office admin directory (this is the directory which you rename when you've just installed prestashop) you will find the following file:

 

themes/default/template/controllers/products/images.tpl

 

Please add the following:

 

{debug}

 

to line 25 of this file so it looks like this

 

*  International Registered Trademark & Property of PrestaShop SA
*}
{debug}
{if isset($id_product) && isset($product)}                                    
<div id="product-images" class="panel product-tab">
    <input type="hidden" name="submitted_tabs[]" value="Images" />
    <div class="panel-heading tab" >

 

 

In the back office select the existing product to which you've added a new image and then select the image tab. Your browser will open a new window full of debug information.

 

Please copy and paste the contents of the $images section, as this will hopefully shed some light on what's going on.

Link to comment
Share on other sites

This sounds like some inconsistency in the database. For example the table image_shop or image_lang might be missing content or you might use a language for which there is no translation.

 

What I would do in such circumstances is:

 - export your database

 - add an image

 - export your database again

 - compare the dumps and find the differences.

 - Now you know how Prestashop deals with images and you can check for one of the defect images.

Link to comment
Share on other sites

On the assumption you're using v1.6:

 

In your back office admin directory (this is the directory which you rename when you've just installed prestashop) you will find the following file:

 

themes/default/template/controllers/products/images.tpl

 

Please add the following:

 

{debug}

 

to line 25 of this file so it looks like this

 

*  International Registered Trademark & Property of PrestaShop SA

*}

{debug}

{if isset($id_product) && isset($product)}                                    

<div id="product-images" class="panel product-tab">

    <input type="hidden" name="submitted_tabs[]" value="Images" />

    <div class="panel-heading tab" >

 

 

In the back office select the existing product to which you've added a new image and then select the image tab. Your browser will open a new window full of debug information.

 

Please copy and paste the contents of the $images section, as this will hopefully shed some light on what's going on.

 

You assumed well. Prestashop 1.6.1.11

 

Here's the resulted of the debug console for the $images section :

$images Smarty_Variable Object (3)

->value = Array (1)

  0 => Image Object (10)

     ->id = 327

     ->id_image = "327"

     ->id_product = "13"

     ->position = "2"

     ->cover = null

     ->legend = Array (3)

      1 => "Biographie d'Yvonne-Aimée de Malestro..."

      2 => "Biographie d'Yvonne-Aimée de Malestro..."

      3 => "Biographie d'Yvonne-Aimée de Malestro..."

     ->image_format = "jpg"

     ->source_index = "/var/www/vhosts/augustines-malestroit..."

     ->id_shop_list = null

     ->force_id = false

->nocache = false

->scope = "file:controllers/products/images.tpl"

 

@musicmaster : I'll try your way if I don't find any easier solution. Coz' I did it already once and didn't find any substantial difference. I'd check, that's true I might have missed something.... But me and databases aren't really BFFs. So if I can find something less annoying than comparing dumps again, I swear I'll do it. Haha. But thanks for the tip, I'll definitely try it if don't find anything else. ^^

Edited by DpHermes (see edit history)
Link to comment
Share on other sites

Thanks for posting the data - this shows that, in this case the back end is only sending one image to display in the table, even if the number in the circle after the IMAGES heading states that there's 3 or 4 images, as you described in your original post.

 

The following code (found in controllers/admin/AdminProductsController.php) gets the total number of images associated with a product. This count is used to display the number in the circle in the IMAGES heading:

$count_images = Db::getInstance()->getValue('                 
                    SELECT COUNT(id_product)                                  
                    FROM '._DB_PREFIX_.'image                                 
                    WHERE id_product = '.(int)$obj->id                        
                );

Note that there is no reference to a language ID - this is literally the number of images associated with a product.

 

The following code assembles the images for display in the table:

 $images = Image::getImages($this->context->language->id, $obj->id);
                foreach ($images as $k => $image) {                           
                    $images[$k] = new Image($image['id_image']);              
                }

This code gets images associated with a given language.

 

My guess is that the language ID assigned to images from your old shop does not match the language ID of the new shop.

 

To check if this is the case, you're going to have to compare the language IDs in the image_lang table for migrated images with language IDs for newly uploaded images.

 

If this guess is correct then you'll be able to update the language ID of the imported images so they match the ID of the newly uploaded images and should appear in the back office once more.

Link to comment
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
×
×
  • Create New...