Jump to content

Use the manufacturers logo as product image


Captain Harlock

Recommended Posts

Hello,

 

I would like to know how to use the manufacturers' logo as a product image instead of the question mark (404.gif) when the product image is missing.

I guess it's located on classes/module/Module.php, on line 1507 :

copy(_PS_IMG_DIR_.'404.gif', _PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg');

But I cannot found the correct thing to write instead

 

Thanks in advance !
 

Link to comment
Share on other sites

I think the easiest solution is to change line 95 of themes/default-bootstrap/product.tpl (in the default PrestaShop v1.6.1.5 theme) from:

						<img itemprop="image" src="{$img_prod_dir}{$lang_iso}-default-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'html':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}"/>

to:

						<img itemprop="image" src="{*{$img_prod_dir}{$lang_iso}-default-large_default.jpg*}{$img_manu_dir}{$product->id_manufacturer}-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'html':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}"/>

This will replace the "No image available" image with the product's manufacturer logo. Note that this will only work if all manufacturers have logos assigned, since it doesn't check whether the manufacturer logo exists. Also, note that it won't work if images are assigned to the product, but those images are missing. You'll still get the question mark in that case.

Link to comment
Share on other sites

Thanks a lot for your answer, but I talked about the "?" (404.gif) image. I noticed that image and the "no image available" pic were not the same file.

Because the problem is : Prestashop assigned a lot of unexisting images to the product, so there are a lot of "?" instead of the picture, I would like to replace with the manufacturer logo.

Link to comment
Share on other sites

In that case, you'll need a more complicated solution. Is it the case that all images for a particular product are missing? If so, we can check for a missing image and then create a variable like $display_manufacturer_logo to display the manufacturer logo on those products.

 

If there is a product with some images working and some not working, the solution becomes even more complicated. You'd have to create an array variable and then add code that displays the working images and replaced the missing images with the manufacturer logo.

Link to comment
Share on other sites

Actually, the images are missing for some products (I mean that Prestashop search for an inexistant pic, like if it assigned a wrong path). And assign image manually would take a huge amount of time.

 

So, there isn't a way to replace the function that generate the 404.gif when an image is missing by a function that search for the product manufacturer id, like I suggest it in my first post ?

Link to comment
Share on other sites

No, PrestaShop doesn't generate individual 404 images for each missing link, it uses a .htaccess file to display the same image for all missing links. Since there's no way for the .htaccess rules to know what manufacturer a product is in, I don't think it's possible to redirect missing product images to that product's manufacturer.

 

I think the only solution is to override controllers/ProductController.php to check whether the images actually exist, then pass a new variable into product.tpl so that you can know which images to replace in that file.

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