Post by dimitar » Thu Oct 12, 2017 5:00 am

I currently select some data from a script directly of the db to export it for getting all customers which applied to the newsletter. But i am struggling with the
data for custom fields.
Right now i get the data with: "SELECT firstname, lastname, email, date_added FROM oc_customer WHERE newsletter = 1" which works fine.
But i have some additional custome fields which i want to add to the selection by joining the tables. I kinda do not understand the structure of custom fields though in the DB. Someone has a clue on how i can get all custom fields beside firstname, lastname, email, date_added?

Newbie

Posts

Joined
Thu Oct 04, 2012 4:33 am

Post by straightlight » Thu Oct 12, 2017 5:21 am

There is no need to reinvent the wheel to pull the customers custom fields. It can easily be done by querying the:

Code: Select all

$this->load->model('account/custom_field');

$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
in the desired controller; where the $customer_group_id would need to be defined in the controller along with your query above and, also, be the customer group ID of those that are part of the newsletters from your query above. Although, from your query above, you'd also need to add the: customer_group_id in the SELECT statement.

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 dimitar » Fri Oct 13, 2017 9:29 pm

straightlight wrote:
Thu Oct 12, 2017 5:21 am
There is no need to reinvent the wheel to pull the customers custom fields. It can easily be done by querying the:

Code: Select all

$this->load->model('account/custom_field');

$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
in the desired controller; where the $customer_group_id would need to be defined in the controller along with your query above and, also, be the customer group ID of those that are part of the newsletters from your query above. Although, from your query above, you'd also need to add the: customer_group_id in the SELECT statement.
Thx for your hint, however the script is just a seperate script from opencart. So what would be the best way to integrate this? I basically thought it might cost too much time to integrate this properly.

Newbie

Posts

Joined
Thu Oct 04, 2012 4:33 am

Post by straightlight » Fri Oct 13, 2017 9:49 pm

If using an API script, you can refer to this solution: viewtopic.php?f=128&t=172429&p=690527&h ... ry#p690535 .

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 OCMDev » Mon Oct 16, 2017 11:24 pm

Hi Dimitar. I don't know what version of Opencart you are using but maybe this can help you:

I just released a Free extension for extracting Customer data and corresponding Custom Fields to Excel (compatible with OC v2.0.1.0 to 2.3.0.2). This extract will provide you with all the data and you will be able to use/format it as you require.

You can Download it here: https://www.opencart.com/index.php?rout ... date_added
You can Test it here: http://www.opencart.ocmdevelopment.com/admin
User: demo / Password: demo

This is a stand alone plugin that can be used together with one of my other extensions: Unlimited Custom Fields to Order Email (more details on http://www.ocmdevelopment.com/)

Hope this helps.

OCMDev
Web: http://www.ocmdevelopment.com/
Contact1: ocmdevelopment@gmail.com
Contact2: contact@ocmdevelopment.com


User avatar
Newbie

Posts

Joined
Tue Jul 11, 2017 10:28 pm
Who is online

Users browsing this forum: No registered users and 68 guests