PHP code example of sholokhov / exchange

1. Go to this page and download the library: Download sholokhov/exchange library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sholokhov / exchange example snippets


use Sholokhov\Exchange\Fields;
use Sholokhov\Exchange\Target\IBlock\Element;

$data = [
    [
        'id' => 56,
        'name' => 'Какой-то элемент',
    ],
    [
        'id' => 15,
        'name' => 'Какой-то элемент 2',
    ]
];

$map = [
    (new Fields\Field)
        ->setPath('id')
        ->setCode('XML_ID')
        ->setPrimary(),
    (new Fields\Field)
        ->setPath('name')
        ->setCode('NAME'),
];

$exchange = new YourExchange;
$exchange->setMap($map);
$result = $exchange->execute($data);