npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

magento-soap-promise

v0.0.3

Published

NodeJS module for Magento 1.x SOAP API using promises

Downloads

47

Readme

Magento Client

Author: Peter Driessen - [email protected]

This module let's you connect with a Magento 1.x webshop via SOAP V2 using the wsdl method. I still need to add a lot of methods, but I also explained how to create a custom method on your own.

Hope this helps you. Please let me know if you have any questions or comments.

Regards, Peter

Usage

Install via npm:

npm i --save magento-soap-promise

// Copyright 2017 Peter Driessen - [email protected]
// MIT License: https://opensource.org/licenses/MIT

'use strict';

const magentoClient = require('magento-soap-promise')

var mag = new magentoClient('https://www.yourdomain.com/api/v2_soap/?wsdl', 'Username', 'ApiKey');

mag.connect().then( sessionid => {
	return mag.getOrder('900000744');
}).then((result) => {
	console.log(JSON.stringify(result));
}).catch( error => {
	console.log(error);
})

Sales Orders Methods

getOrder(increment_id)

Get information about a single order

getPendingOrders()

Get all pending sales orders

getProcessingOrders()

Get all processing orders

commentOrder(increment_id, status, comment)

Add comment to an order, including new status and a comment description

Order Shipments Methods

getShipment(shipment_id)

Get shipment information

commentShipment(shipment_id, comment)

Add comment to a shipment

createShipment(increment_id, comment)

Create a shipment for an order, including a comment

Catalog Methods

getProduct(product_id)

Get product information

getStock(productArr)

Get stock information about one or more products, argument is an array of product ID's

setStock(product_id, qty)

Update stock quantity for a single product

And more to follow...

Custom methods

Basically all methods above make use of the custom method. You can create any method you want, based on the Magento documentation. http://devdocs.magento.com/guides/m1x/api/soap/introduction.html

Example how to create your own method:

  1. Go to http://devdocs.magento.com/guides/m1x/api/soap/catalogInventory/cataloginventory_stock_item.update.html

  2. Have a look at the SOAP V2 example

  3. Copy the method behind $result = $proxy->, which is: catalogInventoryStockItemUpdate

  4. Have a look at the wsdl file you used to connect and search for catalogInventoryStockItemUpdate

  5. You will find this piece of code:

    <message name="catalogInventoryStockItemUpdateRequest">
    	<part name="sessionId" type="xsd:string"/>
    	<part name="product" type="xsd:string"/>
    	<part name="data" type="typens:catalogInventoryStockItemUpdateEntity"/>
    </message>
  6. SessionId is always send along our custom method, product needs a string and data is an argument as well. You have seen these arguments in the documentation at step 1 if it's correct.

  7. You can construct the arguments object like this:

    var args = {
    	product: '2227',
    	data: { 
    		qty: '46' 
    	}
    }
  8. You can now use your custom method like in this full example:

    'use strict';
       
    const mag = require('./magentoClient2');
    var mag = new magentoClient();
    mag.connect('https://www.yourdomain.com/api/v2_soap/?wsdl', 'username', 'apiKey').then( sessionid => {
       
    	// arguments
    	var args = {
    		product: '2227',
    		data: { 
    			qty: '46' 
    		}
    	}
    	return mag.customCall('catalogInventoryStockItemUpdate', args);
       
    }).then((result) => {
       
    	// output result in JSON
    	console.log(JSON.stringify(result));
       
    })