User Tools

Site Tools


urapidflow:v3:run_scheduled

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
urapidflow:v3:run_scheduled [2016/11/01 21:23]
jamby77
urapidflow:v3:run_scheduled [2019/10/17 07:28] (current)
wtsergo
Line 1: Line 1:
 +====== Running uRapidFlow profiles using cron job ======
  
 +<file php urapidflow.php>
 +<?php
 +
 +use Magento\Framework\ObjectManagerInterface;
 +
 +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 = 'adminhtml';
 +/** @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');
 +
 +$omCfgLoaded = $configLoader->load($areaCode);
 +if ($configLoader instanceof \Magento\Framework\App\ObjectManager\ConfigLoader\Compiled) {
 +    $pfsDiVal = @$omCfgLoaded['arguments']['Magento\Catalog\Model\Indexer\Product\Flat\State'];
 +    if (is_array($pfsDiVal) && isset($pfsDiVal['isAvailable']) && is_array($pfsDiVal['isAvailable'])) {
 +        $pfsDiVal['isAvailable']['_v_'] = false;
 +    } elseif (!is_array($pfsDiVal)) {
 +        $pfsDiVal = @unserialize($pfsDiVal);
 +        if (!is_array($pfsDiVal)) {
 +            $pfsDiVal = [];
 +        }
 +        $pfsDiVal['isAvailable'] = false;
 +        $pfsDiVal = serialize($pfsDiVal);
 +    }
 +    $omCfgLoaded['arguments']['Magento\Catalog\Model\Indexer\Product\Flat\State'] = $pfsDiVal;
 +} else {
 +    $omCfgLoaded['Magento\Catalog\Model\Indexer\Product\Flat\State']['arguments']['isAvailable'] = false;
 +}
 +
 +$om->configure($omCfgLoaded);
 +
 +function rfEavExport(ObjectManagerInterface $om)
 +{
 +    runRfProfile($om, "eav-export");
 +}
 +
 +function rfCatExport(ObjectManagerInterface $om)
 +{
 +    runRfProfile($om, "categories-export");
 +}
 +
 +function rfExtraExport(ObjectManagerInterface $om)
 +{
 +    runRfProfile($om, "extras-export");
 +}
 +
 +/**
 + * Function to
 + * @param ObjectManagerInterface $om
 + * @param string|int $profile
 + */
 +function runRfProfile(ObjectManagerInterface $om, $profile)
 +{
 +    /** @var \Unirgy\RapidFlow\Helper\Data $helper */
 +    $helper = $om->get('\Unirgy\RapidFlow\Helper\Data');
 +    $helper->run($profile, true, ['keep_session'=>true]);
 +}
 +
 +rfEavExport($om);
 +
 +rfCatExport($om);
 +
 +rfExtraExport($om);
 +
 +</file>
 +
 +
 +<file cron>
 +# daily import
 +0 1 * * * /usr/bin/php -f /magento/root/urapidflow.php
 +# OR
 +0 2 * * * /usr/bin/lynx -dump http://localhost/magento/urapidflow.php
 +</file>
urapidflow/v3/run_scheduled.1478035400.txt.bz2 · (external edit)