Query to Pull Product Info

I have a Drupal site, but the store is in CS-Cart 2.2.3. I’m trying to pull products from CS-Cart into my Drupal pages using a SQL query, but the product thumbnail image is missing for some products. I can’t figure out how CS-Cart determines where a particular product thumbnail image is stored in the file system. Does anyone where/how the path to the thumbnail image is determined?



Here’s my query:

SELECT<br />
`cscart_products`.`product_id` as ID,<br />
`cscart_product_descriptions`.`product` as TITLE,<br />
`cscart_product_prices`.`price` as PRICE,<br />
`cscart_seo_names`.`name` as PAGE,<br />
`cscart_images`.`image_id` as IMAGE_ID,<br />
`cscart_images`.`image_path` as PATH,<br />
`cscart_categories`.`id_path` as CATEGORY_PATH<br />
FROM `cscart_products` <br />
LEFT JOIN `cscart_product_descriptions`<br />
ON (`cscart_products`.`product_id` = `cscart_product_descriptions`.`product_id`)<br />
LEFT JOIN `cscart_product_prices` <br />
ON (`cscart_products`.`product_id` = `cscart_product_prices`.`product_id`)<br />
LEFT JOIN `cscart_images_links`<br />
ON (`cscart_products`.`product_id` = `cscart_images_links`.`object_id`)<br />
LEFT JOIN `cscart_images` <br />
ON (`cscart_images_links`.`detailed_id` = `cscart_images`.`image_id`)<br />
LEFT JOIN `cscart_seo_names`<br />
ON (`cscart_products`.`product_id` = `cscart_seo_names`.`object_id`)<br />
LEFT JOIN `cscart_products_categories`<br />
ON (`cscart_products`.`product_id` = `cscart_products_categories`.`product_id`)<br />
LEFT JOIN `cscart_categories`<br />
ON (`cscart_products_categories`.`category_id` = `cscart_categories`.`category_id`)<br />
WHERE `cscart_products`.`status` = "A" AND  `cscart_products`.`amount` > 0  AND `cscart_images_links`.`object_type` = 'product' AND `cscart_images_links`.`type` = 'M' AND `cscart_seo_names`.`type` = 'p' AND `cscart_products_categories`.`link_type` = 'M'<br />
GROUP BY `cscart_products`.`product_id` <br />
ORDER BY `cscart_products`.`timestamp` DESC<br />
LIMIT 5<br />
<br />

Hi @grayloon,

Thumbnail is not stored into database.



This will help:
define('DIR_ROOT', '');//path to root
define('MAX_FILES_IN_DIR', 1000); //is located into config.local.php
define('IMAGE_ID',/* IMAGE_ID from query result */);
define('PATH',/* PATH from query result */);

$image_id = IMAGE_ID;
$thumb_width = ''; //you found to admin.php?dispatch=settings.manage§ion_id=Thumbnails
$thumb_height = ''; //you found to admin.php?dispatch=settings.manage§ion_id=Thumbnails
$image_name = PATH;

$thumb = DIR_ROOT.'/images/thumbnails/'.floor($image_id/MAX_FILES_IN_DIR).'/'.$thumb_width.((empty($thumb_height))?'':'/'.$thumb_width).'/'.$image_name;
if(file_exists($thumb)){
//thumbnail has been generated and you can used
}else{
//thumbnail has not been generated
}






Please get back here if any more clarifications.





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

Might be easier to do a fn_get_product_data($product_id, $auth) which will resolve your detail/thumbnail stuff and give you the paths to the images.

[quote name='tbirnseth' timestamp='1376793306' post='166983']

Might be easier to do a fn_get_product_data($product_id, $auth) which will resolve your detail/thumbnail stuff and give you the paths to the images.

[/quote]

I like this approach. Which files would I need to include in my Drupal PHP page to allow that function to work?

Go look at the Google Data Feeds cron interface to give you an idea of what you need to do to “load” cs-cart so you can use it' as an API.