# magento-soap-promise

> NodeJS module for Magento 1.x SOAP API using promises

Latest version **0.0.3** (published 2017-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install magento-soap-promise
pnpm add magento-soap-promise
yarn add magento-soap-promise
bun add magento-soap-promise
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-10-08 |
| First published | 2017-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Peter Driessen - info@studioio.io |
| Maintainers | peterdriessen |
| Keywords | magento, soap, promises, nodejs, wsdl |

## Links

- npm: https://www.npmjs.com/package/magento-soap-promise
- Repository: https://github.com/p3sn/magento-soap-promise
- Homepage: https://github.com/p3sn/magento-soap-promise#readme
- Issues: https://github.com/p3sn/magento-soap-promise/issues
- npm.io page: https://npm.io/package/magento-soap-promise

## Dependencies (1)

- [strong-soap](https://npm.io/package/strong-soap.md) ^1.2.6

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2017-10-08
- 0.0.2 — 2017-10-08
- 0.0.1 — 2017-10-08

## README

# Magento Client

Author: Peter Driessen - info@studioio.io

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: 

```javascript
npm i --save magento-soap-promise
```


```javascript

// Copyright 2017 Peter Driessen - info@studioio.io
// 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:
	
	```html
	<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: 
	
	```javascript
	var args = {
		product: '2227',
		data: { 
			qty: '46' 
		}
	}
	```
8. You can now use your custom method like in this full example:

	```javascript	
	'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));
	
	})
	
	```

---
_Source: https://npm.io/package/magento-soap-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
