node.js - Combined complex filter for ranges in Nodejs -


on magento 1.8 soap apiv2, i'm looking way date range retrieve information soap api. have consulted query stackoverflow i.e combined complex filter ranges. need apply same type of complex filters in node project. curently using magento node wrapper i.e https://github.com/madisonreed/magentoapi

exports.find = function (req, res) {   async.waterfall([     function (done) {       magento.login(function(err, sessid) {         if (err) {           // deal error           console.log('login error:' + err);           return;         }         done(err, done);         // http://localhost/api/rest/customers       });     },      function (filteredcustomer, done) {       var attributes = [];       var filteredcustomer = [];       magento.customer.list({filters: [  ]},function(err, customercollection) {         _.foreach(customercollection, function(customer, key) {           var attributes = _.pick(customer, [             'customer_id',             'created_at',             'updated_at',             'firstname',             'lastname',             'gender',             'credit_value',             'customer_referral_code',           ]);           var customerdocument = {             'email': customer.email,             'number': customer.contact_no,             'created_at': date.now(),             'initialsource': 'magento',             'attributes': attributes           };           filteredcustomer.push(customerdocument);         });         done(filteredcustomer);       });     },     function (filteredcustomer, done) {       console.log(filteredcustomer);       if(!err){         done(filteredcustomer);       }     }   ],   function (err) {     if (err) {       console.log(err);     }   }); }; 

output:

[   {      email: 'rht.rai2@gmail.com',     number: '1313543132',     created_at: 1478785224233,     initialsource: 'magento',     attributes:       { customer_id: '1',        created_at: '2016-03-10 04:39:16',        updated_at: '2016-10-03 10:09:21',        firstname: 'rohit',        lastname: 'rai',        gender: '1',        credit_value: '0.0000',        customer_referral_code: 'ds518'       }   },     {     email: 'rajveer@gmailj.com',     number: '9088694978',     created_at: 1478785224233,     initialsource: 'magento',     attributes:       {         customer_id: '2',        created_at: '2016-04-10 23:52:05',        updated_at: '2016-11-04 05:22:09',        firstname: 'rajveer',        gender: '1',        credit_value: '0.0000',        customer_referral_code: 'cw624'       }   },  {      email: 'rohit@happilyunmarried.com',     number: '1321321231',     created_at: 1478785224233,     initialsource: 'magento',     attributes:       {         customer_id: '3',        created_at: '2016-07-11 05:00:55',        updated_at: '2016-11-07 10:03:54',        firstname: 'rohit',        gender: '1',        credit_value: '0.0000',        customer_referral_code: 'aj318'       }   }  ] 

i figured out way send data in magento , required result in node. working smooth. hope helps.

'use strict';  /**  * module dependencies.  */ var path = require('path'),   mongoose = require('mongoose'),   errorhandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller')),   _ = require('lodash'),   customers = mongoose.model('customers'),     async = require('async'),       moment = require('moment');  var magentoapi = require('magento');  var magento = new magentoapi({   host: 'localhost',   port: 80,   path: '/happilyustraa/api/xmlrpc/',   login: 'rhtrai',   pass: 'rohitisla' });      exports.find = function (req, res) {   async.waterfall([     function (done) {       magento.login(function(err, sessid) {         if (err) {           // deal error           console.log('login error:' + err);           return;         }         done(err, done);         // http://localhost/api/rest/customers       });     },      function (filteredcustomer, done) {       var attributes = [];       var filteredcustomer = [];       magento.customer.list({filters: {"created_at": {'from': "2016-03-10 04:39:16"}, "created_at":{ 'to': "2016-04-10 23:52:05"}   } },function(err, customercollection) {         _.foreach(customercollection, function(customer, key) {           // var attributes = _.pick(customer, [           //   'customer_id',           //   'created_at',           //   'updated_at',           //   'firstname',           //   'lastname',           //   'gender',           //   'credit_value',           //   'customer_referral_code',           // ]);           // var customerdocument = {           //   'email': customer.email,           //   'number': customer.contact_no,           //   'created_at': date.now(),           //   'initialsource': 'magento',           //   'attributes': attributes           // };           // filteredcustomer.push(customerdocument);           console.log(customer);         });         done(filteredcustomer);       });     },     function (filteredcustomer, done) {       // console.log(filteredcustomer);       if(!err){         done(filteredcustomer);       }     }   ],   function (err) {     if (err) {       console.log(err);     }   }); }; 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -