s25/prices-importer

Simplifies the process of importing prices into the S25 prices service

2.2.0 2023-09-29 07:56 UTC

This package is auto-updated.

Last update: 2024-04-29 09:13:23 UTC


README

Prerequisites

The Importer requires an external PSR7-compliant HTTP Client such as Guzzle.

Example

$csv = new \S25\PricesImporter\CsvFile();

$csv->add(['bransslug1', 'RAWPARTNUMBER1'], 12.3 'CUR');
$csv->add(['bransslug2', 'RAWPARTNUMBER2'], 45.6 'REN', 10);
$csv->add('guid3', 78.9 'CYC');
    
$importer = new \S25\PricesImporter\Importer(
    'http://service.url/import',
    new \GuzzleHttp\Client(),
    new \GuzzleHttpHttpFactory(),
);

try {
    $importer->send(
        'price-list-key',
        $csv,
        'Optional source filename'
    );
} catch (\RuntimeException $e) {
    // Something went wrong
}