Jump to content

Cover images in multistore setup is broken


Dreeuwtje

Recommended Posts

Hi, 

I upgraded to the latest version (1.6.1.16) and notice that it is no longer possible to change the cover images on a product when changing it for all shops at once. 

 

When changing the image for a single shop it works fine (the specific entry in the table shop_image is updated). 

But if no specific shop is selected (i want to have the same cover image for all shops), all entries in shop_image are set to NULL. 

In table 'image' the entry is correctly updated, but this does not seem to be used (in the backend nor on the frontend). 

 

Can we have a fix for that? 

 

Note: i'm not sure until which version it did work.

 

Regards,

 

Dreeuwtje

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

I took a minute to fix it myself

 

diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php

index 957d538..51285de 100644

--- a/controllers/admin/AdminProductsController.php

+++ b/controllers/admin/AdminProductsController.php

[spam-filter] -1656,14 +1656,33 [spam-filter] class AdminProductsControllerCore extends AdminController

         if ($this->tabAccess['edit'] === '0') {

             return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));

         }

+

+        $res = true;

+

         Image::deleteCover((int)Tools::getValue('id_product'));

         $img = new Image((int)Tools::getValue('id_image'));

+

         $img->cover = 1;

 

         @unlink(_PS_TMP_IMG_DIR_.'product_'.(int)$img->id_product.'.jpg');

         @unlink(_PS_TMP_IMG_DIR_.'product_mini_'.(int)$img->id_product.'_'.$this->context->shop->id.'.jpg');

 

-        if ($img->update()) {

+

+        $res &= Db::getInstance()->execute('

+                       UPDATE `'._DB_PREFIX_.'image`

+                       SET `cover` = 1

+                       WHERE `id_product` = '.(int)Tools::getValue('id_product').' AND id_image = '.(int)Tools::getValue('id_image').';'

+        );

+        $res &= Db::getInstance()->execute('

+                       UPDATE `'._DB_PREFIX_.'image_shop` image_shop

+                       SET image_shop.`cover` = 1

+                       WHERE image_shop.id_shop IN ('.implode(',', array_map('intval', Shop::getContextListShopID())).') AND image_shop.`id_product` = '.(int)Tools::getValue('id_product') .' AND id_image = '.(int)Tools::getValue('id_image').';'

+        );

+

+        $res &= $img->update();

+

+        if ($res) {

             $this->jsonConfirmation($this->_conf[26]);

         } else {

 

             

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

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...