Jump to content

Script/module for give to he pictures the same name than the title at all the images


Derres

Recommended Posts

Assuming you have only one shop with ID 1, you could use the following query:
UPDATE `ps_image_lang` il
SET `legend` = (
​    SELECT `name`
​    FROM `ps_product_lang` pl
​    WHERE il.`id_lang` = pl.`id_lang` AND pl.`id_shop` = 1 AND pl.`id_product` = (
​        SELECT `id_product`
​        FROM `ps_image` i
​        WHERE i.`id_image` = il.`id_image`
​    )
)

Note that this will overwrite all your existing image titles, so make sure to back up first. A more complicated query will be needed if you have multiple shops.

Link to comment
Share on other sites

You can add the following to the end of the query above to restrict to some product IDs:

WHERE il.`id_image` IN (
​    SELECT `id_image`
​    FROM `ps_image` i
​    WHERE i.`id_product` IN (4, 5, 6)
)

Change 4, 5, 6 to the IDs of the products you want to update.

 

Or you can add the following to the end of the query for a range of products:

WHERE il.`id_image` IN (
​    SELECT `id_image`
​    FROM `ps_image` i
​    WHERE i.`id_product` >= 4 AND i.`id_product` <= 6
)

Change 4 to the lowest product ID you want updated and 6 to the highest product ID.

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