Imajica929 Posted October 9, 2020 Share Posted October 9, 2020 Afternoon Folks, I am working on a new cubecart site that has an accompanying blog and I'd like to display the contents of the Featured Product box in he sidebar of the blog site Does anyone know how to pull that off? John Link to comment Share on other sites More sharing options...
bsmither Posted October 9, 2020 Share Posted October 9, 2020 Welcome Imajica929! Glad to see you made it to the forums. CubeCart does not have an externally accessible API that would return this data, but one could be built. We would have to assume that you already have the capability and skill to write the blog's request and consume the returned data. On the other hand, if you can convince the blog to access CubeCart's database directly, all the pertinent data could be queried independently. Link to comment Share on other sites More sharing options...
Imajica929 Posted October 9, 2020 Author Share Posted October 9, 2020 Thanks bsmither might be a little over my head.. I'm an infrastructure guy, not a developer but I'm wiling to give it a shot John Link to comment Share on other sites More sharing options...
bsmither Posted October 9, 2020 Share Posted October 9, 2020 (You may need to reload this forum conversation. I added another idea.) Which approach would like to explore? 1. An API call. or 2. Direct access to the database Link to comment Share on other sites More sharing options...
Imajica929 Posted October 9, 2020 Author Share Posted October 9, 2020 Database I speak... API call I'd have to learn.. but learning is not out of the question John Link to comment Share on other sites More sharing options...
bsmither Posted October 9, 2020 Share Posted October 9, 2020 CubeCart's "Featured" is actually a random pick from all products whose featured flag is set. Modify the following query to have the database engine pick one random record -or- only have set one product's Featured setting checkbox to a checked state. SELECT * FROM `CubeCart_inventory` WHERE CubeCart_inventory.status = '1' AND CubeCart_inventory.featured = '1'; Take note of the 'product_id' of the returned row. Use it in the next two queries. SELECT `path` FROM `CubeCart_seo_urls` WHERE CubeCart_seo_urls.type = 'prod' AND CubeCart_seo_urls.item_id = $product_id; SELECT `file_id` FROM `CubeCart_image_index` WHERE CubeCart_image_index.product_id = $product_id ORDER BY `main_img` DESC LIMIT 1; Take note of the 'file_id' of the returned row. Use it in the next query. SELECT `filepath`, `filename` FROM CubeCart_filemanager WHERE CubeCart_filemanager.file_id = $file_id; Use 'filepath' and 'filename' to construct an <img> tag for the product's image. Use 'path' to construct a web address to the product in the CubeCart store. Link to comment Share on other sites More sharing options...
Imajica929 Posted October 9, 2020 Author Share Posted October 9, 2020 interesting way to go about that... I'm off to play Thanks bsmither! I appreciate the lead John Link to comment Share on other sites More sharing options...
Imajica929 Posted October 14, 2020 Author Share Posted October 14, 2020 I'll admit it.. I cheated.. a lot I made a copy of index.php and changed the display to 'templates/box.featured.php' I can run that in a iframe or call it from an include with some additional massaging I'll play with the database method after we go live and I have a little more time :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.