https://github.com/superreal/edi-parser
https://github.com/superreal/edi-parser
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/superreal/edi-parser
- Owner: superReal
- Created: 2013-01-11T16:41:11.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-03-21T10:40:58.000Z (about 12 years ago)
- Last Synced: 2025-02-19T17:06:36.097Z (over 1 year ago)
- Language: PHP
- Size: 376 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
edi-parser
==========
This is a parser for [UN/EDIFACT](https://de.wikipedia.org/wiki/EDIFACT) messages.
## Usage
To parse a message initialize a new EDIParser Instance with a path to the file you want to parse.
```php
//To
$parser = new EDIParser(__DIR__ . "/PAORES.edi");
$parser->parse();
```
To retrieve the parsed message call:
```php
$oMessage = $parser->getOMessage();
```
#INVRPT (Inventory report message)
The only message type implemented at the moment is [INVRPT](http://www.unece.org/trade/untdid/d08a/trmd/invrpt_c.htm).
An INVRPT basically consists of several LINE ITEM Elements ([LIN](http://www.unece.org/trade/untdid/d08a/trsd/trsdlin.htm)), each followed by a QUANTITY Element ([QTY](http://www.unece.org/trade/untdid/d08a/trsd/trsdqty.htm)).
Example:
```php
foreach($this->oMessage->getLineItems() as $oLineItem) {
if (in_array($oLineItem->getItemNumber(), array_keys($aVariantIds))) {
$aStockChanges[] = array(
'OXID' => $aVariantIds[$oLineItem->getItemNumber()],
'OXSTOCK' => $oLineItem->getQuantity()
);
$aParentChanges[] = array(
'OXID' => $aParentIds[$oLineItem->getItemNumber()]
);
}
}
```
To retrieve the Line Items from the Message call:
```php
$oMessage->getLineItems();
```
Methods available on Line Item Objects (LIN) to ease access to parsed data:
```php
$oLIN->getLineItemNumber();
$oLIN->getActionRequest();
$oLIN->getItemNumber();
$oLIN->getItemNumberType();
$oLIN->getQuantityQualifier();
$oLIN->getQuantity();
$oLIN->getMeasureUnit();
```