Retrieve thumbnails from Database

Hey all,

I’ve been trying to figure out the logic which cs-cart uses to grab a thumbnail image (main thumb) straight from the database. Is there anyone here who knows how to do it with SQL?

Until now i can’t seem to figure out what the right thumbnail for a product is, seems like i keep overlooking some kind of important table or field value…

And besides that, the thumbs are now put into folder like thumbnails/0/120/ and thumbnails/1/120 etc, where the … is that stored in the database?

So, to keep it simple, let me summarize:

Does anyone know the SQL query to grab the complete main thumbnail url straight from the database?

You need to know the product_id. Then

SELECT i.image_path FROM cscart_images_links as L LEFT JOIN cscart_images as i ON L.image_id=i.image_id WHERE L.object_id=863 AND L.object_type='product' AND L.type='M'

hi tbirnseth,

Your query is giving me NULL als result.Whatever product_id i use.

And i don’t think it does what i want anyway, because the images_links table seems to only contain 1 image reference for a product, which isn’t always the thumbnail. And besides that, image_id in images_links table seems to always be 0 when it’s a product.

The entire image handling seems chaos to me…

You said you wanted the thumbnail. Using the image_id (versus the detailed_id) and type = ‘M’ (main pair) would resolve to the thumbnail. Note that is the filename. The actual path is done by logic in the code, not stored in the database and is based on the image_id.

I believe I wrote the quiery based on 2.1.2 schema. Sorry it doesn’t work for you, was only trying to help.

This is really helping me… its the only sql example I have been able to find in relation to the product data.

Is there any other examples, or Schema info you might be able to point me toward?


I have looked through that page before (and again now).

It doesn’t give a data structure breakdown.

Also I am connecting from outside the Cs-cart app, (another domain on the same server)

so I don’t have access to the carts framework.

I think that it would help many of us that are just getting started developing with the cart.

Actually it is not as hard as you think. The 200+ tables in the database are clearly named on what data they collect. The developers did an excellenct job doing this.

For example:

cscart_products_categories - contains all the product category data

cscart_category_descriptions - contains the category names and descriptions

All of the product data are in the tables begining with cscart_products

All of the product options are in tables beginning with cscart_product_options

All of the order data are in tables beginning with cscart_orders

Basically what I am saying is look at the table names and begin there. Yes one table will reference several other tables, but the flow makes sense and is not that hard to follow.

For example:

table cscart_product_options uses table cscart_product_options_descriptions and table cscart_product_option_variants and table cscart_product_option_variants_descriptions, but if you look at it that makes sense that those tables reference each other.