bluehat09 Posted February 13, 2012 Share Posted February 13, 2012 I'm trying to do a WP plugin that will show PrestaShop products randomly from the whole database and from one specified category. I need to construct the image path for a product having the product id only. All I ask is a SQL query that will help me to construct the right path to the right image for the right product. I know the default path is img/p/product_id/image_id/product_idimage_id-home.jpg and that's all I need. E.g.: \img\p\1\5\15-home.jpg For the purpose of simplicity I will ignore the colors and the language. My problem is how to get the image_id I suppose is all about left join some tables. Any suggestion is welcomed. Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 14, 2012 Share Posted February 14, 2012 Hello, this is the query: SELECT id_image FROM image WHERE id_product = [iD_PRODUCT] AND cover = 1 or SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend` FROM [DB_PREFIX]product p LEFT JOIN `[DB_PREFIX]product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = [iD_LANG]) LEFT JOIN `[DB_PREFIX]image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `[DB_PREFIX]image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = [iD_LANG]) Link to comment Share on other sites More sharing options...
bluehat09 Posted February 16, 2012 Author Share Posted February 16, 2012 Thanks. I will try this. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now