User Tools

Site Tools


urapidflow:v3:file_preprocess

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
urapidflow:v3:file_preprocess [2016/11/01 21:20]
jamby77 created
urapidflow:v3:file_preprocess [2017/05/19 19:08] (current)
Line 1: Line 1:
 +<file php bootstrap.php>​
 +<?php
 +// initialize Magento environment
  
 +try {
 +//    if you move this file, adjust bootstrap.php path
 +    require __DIR__ . '/​../​../​../​../​../​app/​bootstrap.php';​
 +} catch (\Exception $e) {
 +    echo <<<​HTML
 +{$e->​getMessage()}
 +</​div>​
 +HTML;
 +    exit(1);
 +}
 +
 +$params = $_SERVER;
 +$params[\Magento\Store\Model\StoreManager::​PARAM_RUN_CODE] = '​admin';​ // change this to appropriate store if needed.
 +$params[\Magento\Store\Model\Store::​CUSTOM_ENTRY_POINT_PARAM] = true;
 +$bootstrap = \Magento\Framework\App\Bootstrap::​create(BP,​ $params); // bootstrap
 +
 +/** @var \Magento\Framework\App\Http $app */
 +$app = $bootstrap->​createApplication('​Magento\Framework\App\Http'​);​
 +
 +// configure environment
 +$om = $bootstrap->​getObjectManager();​
 +$areaList = $om->​get('​Magento\Framework\App\AreaList'​);​
 +$areaCode = $areaList->​getCodeByFrontName('​admin'​);​
 +/** @var \Magento\Framework\App\State $state */
 +$state = $om->​get('​Magento\Framework\App\State'​);​
 +$state->​setAreaCode($areaCode);​
 +/** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
 +$configLoader = $om->​get('​Magento\Framework\ObjectManager\ConfigLoaderInterface'​);​
 +$om->​configure($configLoader->​load($areaCode));​
 +// end initialize Magento environment
 +
 +</​file>​
 +
 +<file php urapidflow.php>​
 +<?php
 +include __DIR__ . '/​bootstrap.php';​
 +
 +// download from http location
 +$res = @copy('​http://​remote.server.com/​archive.zip',​ $targetDir . '​archive.zip'​);​
 +if ($res !== true) {
 +    echo 'ERROR downloading file';
 +    exit;
 +}
 +
 +// unpack the archive
 +$zip = new ZipArchive();​
 +$res = $zip->​open($targetDir . '​archive.zip'​);​
 +if ($res !== true) {
 +    echo 'ERROR unpacking archive';​
 +    exit;
 +}
 +$zip->​extractTo($targetDir);​
 +$zip->​close();​
 +
 +// run the profile, which should be associated with final import file
 +$om->​get('​\Unirgy\RapidFlow\Helper\Data'​)->​run('​Your Import Profile'​);​
 +
 +</​file>​
urapidflow/v3/file_preprocess.txt · Last modified: 2017/05/19 19:08 (external edit)