TonyKapa Posted June 16, 2022 Share Posted June 16, 2022 Hello! I am developing a module where I want to show in the home page for example the last 10 products that got sold, how can I get their ID's ? Thanks in advance! Link to comment Share on other sites More sharing options...
Nickz Posted June 16, 2022 Share Posted June 16, 2022 I think that Module is unnecessary. You can filter your sales after all kinds factors. 1 Link to comment Share on other sites More sharing options...
TonyKapa Posted June 16, 2022 Author Share Posted June 16, 2022 So how do you suggest I do that? Is there a native module that can do that? Link to comment Share on other sites More sharing options...
Mediacom87 Posted June 16, 2022 Share Posted June 16, 2022 Hi, You can have this list of products by going to the Statistics menu and selecting the Catalog Evaluation tab. In this part, you can select a period and then sort the list of products by number of sales. 1 1 Link to comment Share on other sites More sharing options...
TonyKapa Posted June 16, 2022 Author Share Posted June 16, 2022 Thanks for your replies , Maybe I was unclear, I want to show those products front end,to the customers. In my eshop Home page not admin home page. And I want to do it dynamically, with each new order, products shown in front home page will be updated automatically with the newly sold items. Link to comment Share on other sites More sharing options...
Mediacom87 Posted June 16, 2022 Share Posted June 16, 2022 Do it with a simple SQL query where you get the product id of the last orders and then work on it. 1 Link to comment Share on other sites More sharing options...
Ress Posted June 17, 2022 Share Posted June 17, 2022 Hi, The products purchased are in the ps_order_detail table. Basically, you just have to make a select, ordering them in descending order. If you want something more complex, you can also check the current status of the order that the products are part of, so that it is not a canceled order, or one that has not yet been processed. 1 Link to comment Share on other sites More sharing options...
Tom Girou Posted June 17, 2022 Share Posted June 17, 2022 50 minutes ago, Ress said: Hi, The products purchased are in the ps_order_detail table. Basically, you just have to make a select, ordering them in descending order. If you want something more complex, you can also check the current status of the order that the products are part of, so that it is not a canceled order, or one that has not yet been processed. Indeed. Also use LIMIT 10 in your SQL query, to get only the 10 latest instead of filtering in PHP. 1 Link to comment Share on other sites More sharing options...
TonyKapa Posted June 17, 2022 Author Share Posted June 17, 2022 Thanks for the help it works fine $request = 'SELECT `product_id` FROM `' . _DB_PREFIX_ . 'order_detail` ORDER BY `id_order` DESC LIMIT 10' Link to comment Share on other sites More sharing options...
Mediacom87 Posted June 17, 2022 Share Posted June 17, 2022 Don't forget to used DISTINCT if you really get 10 lasts unique products 1 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