Post by Cue4cheap » Sun Oct 17, 2021 7:47 am

OC 2.3.0.2
I am a bit lost on how to approach logging products ordered. This is a pretty specific thing as I am attempting to get a simple text file of all product models ordered that day. This is for statistics gathering and is just an idea, not anything completely thought out...
It doesn't need to have anything besides the model. I don't care about options.
My initial thought was after the order is processed to write all models to a txt file but I am drawing a blank on what would be the best way to go about this.
Would anyone be kind enough to give me their opinion?
Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by Cue4cheap » Sun Oct 17, 2021 11:20 am

May not be the best but for now put a function to be called in catalog/model/checkout/order.php
under
// Products
To log the model into a simple text file.

On to figure out how to do it the right way tomorrow.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Sun Oct 17, 2021 11:33 am

Cue4cheap wrote:
Sun Oct 17, 2021 11:20 am
May not be the best but for now put a function to be called in catalog/model/checkout/order.php
under
// Products
To log the model into a simple text file.

On to figure out how to do it the right way tomorrow.
Mike
Or, by creating an Event trigger whenever the addOrderHistory method is being called from the OC admin API orders: https://github.com/opencart/opencart/wiki/Events-System

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

Post by paulfeakins » Mon Oct 18, 2021 5:58 pm

Cue4cheap wrote:
Sun Oct 17, 2021 7:47 am
I am a bit lost on how to approach logging products ordered.
Just find a reports extension that does this.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Gergely » Mon Oct 18, 2021 6:43 pm

Hi Mike,

I don't know if you are already aware, but opencart ships with a Products Purchased Report feature. It is quite rudimentary for a report, but might just be enough for what you need.

Alternatively, as paulfeakins said, there are ready-made solutions on the Marketplace. For example, the more advanced Import/Export tools on the Marketplace let you set up csv exports from any database table / combinations thereof with functionality to set up cron jobs, etc.

Of course, if you are looking for the right way to develop such functionality, go with straightlight's suggestion.

Hope this adds some useful info!
Gergely

Active Member

Posts

Joined
Wed Sep 30, 2020 7:58 pm

Post by straightlight » Mon Oct 18, 2021 9:58 pm

A cron job may not be necessary in this case since the addOrderHistory can already be triggered upon every transactions. Which means, a TXT file can be created and appended from an Event Trigger automatically based on each purchased products on-the-fly. It's just not a compliant way, at least not anymore, to output data into an archived file in regards of POS transactions but rather to use a service.

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: Bing [Bot] and 63 guests