[UPDATE 2023] Use the default combination image, with a non-zero quantity, as the cover image in Prestashop

Publié par David Sprang le

Update 2023

I was really hanging over a problem with a website. In fact, the products have a lot of combination (colors). Because it is related with fashion accessories. The thing is, some colors were simply not remade because of the complexity of certain material. So, a lot of products miniature in product-list were displaying « out-of-stock » or « Product available with different options » and it will never change!

Before SQL script

After SQL script

I just thought it would be interesting to create an Add-on to the SQL script I designed on my blog, which would be:

  • Check all the products combinations which are the default combination and have a stock quantity of zero
    • Set them to not the default combination
    • Use the combination of this product with the max stock quantity as default
  • Use the old SQL script: set the cover images as the images of the default combination

Introduction

You can import the default image of a product with CSV import, but you cannot import the cover image. For example, it is very important to select a good bunch of images for the products with different colors. If you sell t-shirts and all the cover images show white t-shirts, your webshop will lack of identity.

The easiest way is to import the default image and use a SQL request to set the same cover image than the default image.

Disabling the combination with 0-stock

Set the default combination images as cover images

  • First, you need to have set all the default image in your catalog. You can do this automatically by importing a CSV file.
  • Open your database (for example by PhpMyAdmin)
  • Create backup of your database for safety (export data and structure)
  • Open SQL tab and perform queries from this file (change ‘ps_’ to your prefix):

If Advanced Stock Module is enabled

The script would change a little. Here is the total SQL:

 

 

Catégories : Prestashop

0 commentaire

Laisser un commentaire

Emplacement de l’avatar

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *