PHP code example of contentreactor / craft-importer

1. Go to this page and download the library: Download contentreactor/craft-importer 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/ */

    

contentreactor / craft-importer example snippets


new \ContentReactor\Importer\Importers\BaseFileImporter(
	section: 'yourSectionHandle',
	importerType: \ContentReactor\Importer\Base\ImporterType::IMPORTER_TYPE_FILE,
	foundStrategy: \ContentReactor\Importer\Base\FoundStrategy::OVERWRITE,
	notFoundStrategy: \ContentReactor\Importer\Base\NotFoundStrategy::DELETE,
	filePath: '/full/system/path/to/your/file.xml', // <- the extension must match the fileType, or be compatible with the MIME type
	fileType: \ContentReactor\Importer\Services\Imports::FILE_XML,
	dataPath: 'comma.separated.nesting.is.supported',
	slugKey: 'slug-key',
	titleKey: 'titleKey',
	primaryKey: 'primary_key', // if 'slug', the `primaryKeyValue` will be tested as slugified
	primaryKeyValue: 'value used to look for existing elements', // relevant for `foundStrategy` and `notFoundStrategy`
),

new \Your\Namespace\Importer(
	section: 'anotherSectionHandle',
	filePath: 'www.example.com/awesome-import-data.json',
	// If the constructor