Post by ultraspoon » Thu Jan 05, 2012 11:58 pm

Ive noticed that someone already made a post on this just under 12 months ago but no reply.

However I am quite interested in this, how would you go about displaying certain products outside of opencart, such as on another website? Is it possible?

Thank you

Active Member

Posts

Joined
Mon Oct 18, 2010 5:56 pm

Post by d7a7z7e7d » Fri Jan 06, 2012 12:06 am

You could use an RSS feed or you could just connect directly to the DB and grab the items you need.

This one shows the latest products:

http://www.opencart.com/index.php?route ... on_id=1540

This one lets you create one for categories, specials or brands:

http://www.opencart.com/index.php?route ... on_id=3949

Image
OpenCart Extensions, Technical Support & Custom Development | Have I helped you?


User avatar
Active Member

Posts

Joined
Fri Sep 17, 2010 5:51 am
Location - USA

Post by ultraspoon » Fri Jan 06, 2012 8:46 pm

Hi d7a7z7e7d,

Thanks for your reply, I might go with that RSS feed to be honest, it seems like the easiest, and most efficient route, plus I get to help out UKSB a little bit for his efforts.
I have emailed him asking to enable that RSS feed on his demo store so I can check it out so fingers crossed.

Just incase that is not really what Im looking for, do you know anything about SQL, im not to great with it myself. I know how to connect to the database and I do have an idea of how to grab things from it but im a little stuck on how to do it with opencart.

You see, I dont want to grab all items from the DB, only products from a specific category. Could you or anyone point me in the right direction with a spot of code please?

Thank you for advice

Active Member

Posts

Joined
Mon Oct 18, 2010 5:56 pm

Post by d7a7z7e7d » Fri Jan 06, 2012 10:18 pm

Good news, I found an extension for a RESTful API, which would be the proper way to go about this. It's a little bit bare-bones but it does come with some sample functions like getProducts() and looks like it's exactly what you'd need, with some minor modifications. Check it out:

http://opencart.hostjars.com/opencart-rest-api

Basically you'll just need to write a getProductsByCategory() function, which I could help you with, and then you'd just access the data by cURLing the URL: http://www.example.com/index.php?route= ... ByCategory

Image
OpenCart Extensions, Technical Support & Custom Development | Have I helped you?


User avatar
Active Member

Posts

Joined
Fri Sep 17, 2010 5:51 am
Location - USA

Post by comprido » Sat Sep 04, 2021 6:34 pm

With this query (you can customize easily) you'll be getting 10 latest products from store_id 0, category 230, manufacturer 17 with "keyword" to build nice SEO friendly links to your store. O0

Code: Select all

SELECT `oc_product`.`product_id`,`name`,`description`,`image`,`keyword`FROM `oc_product`
LEFT JOIN `oc_product_to_category`
   ON `oc_product_to_category`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_product_description`
   ON `oc_product_description`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_product_to_store`
   ON `oc_product_to_store`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_url_alias`
   ON (`oc_url_alias`.`query` LIKE  CONCAT('%',`oc_product`.`product_id`,'%'))
WHERE `oc_product_to_category`.`category_id` = '230' AND `oc_product`.`status` = '1' AND `oc_product`.`date_available` <= NOW() AND `oc_product`.`manufacturer_id`='17' AND `oc_product_to_store`.`store_id` = '0'
ORDER BY `oc_product`.`product_id` DESC LIMIT 10

Pedro Martin - websitesbuilder.com.au
Checkout my free extensions: https://www.opencart.com/index.php?rout ... r=comprido


User avatar
New member

Posts

Joined
Mon Sep 10, 2012 11:46 pm

Post by straightlight » Sat Sep 04, 2021 7:55 pm

comprido wrote:
Sat Sep 04, 2021 6:34 pm
With this query (you can customize easily) you'll be getting 10 latest products from store_id 0, category 230, manufacturer 17 with "keyword" to build nice SEO friendly links to your store. O0

Code: Select all

SELECT `oc_product`.`product_id`,`name`,`description`,`image`,`keyword`FROM `oc_product`
LEFT JOIN `oc_product_to_category`
   ON `oc_product_to_category`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_product_description`
   ON `oc_product_description`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_product_to_store`
   ON `oc_product_to_store`.`product_id` = `oc_product`.`product_id`
LEFT JOIN `oc_url_alias`
   ON (`oc_url_alias`.`query` LIKE  CONCAT('%',`oc_product`.`product_id`,'%'))
WHERE `oc_product_to_category`.`category_id` = '230' AND `oc_product`.`status` = '1' AND `oc_product`.`date_available` <= NOW() AND `oc_product`.`manufacturer_id`='17' AND `oc_product_to_store`.`store_id` = '0'
ORDER BY `oc_product`.`product_id` DESC LIMIT 10
In order for that to happened, the remote platform on the same domain must either use PHP PDO which can take a great amount of socket resources between environments, or maintain the same database resource (less suggested unless using a dedicated fully managed server). Alternatively, the data could be feed by using the same catalog model product: viewtopic.php?f=202&t=220903#p805005 .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 57 guests