urapidflow:v3:run_scheduled
Running uRapidFlow profiles using cron job
- 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);
# daily import
0 1 * * * /usr/bin/php -f /magento/root/urapidflow.php
# OR
0 2 * * * /usr/bin/lynx -dump http://localhost/magento/urapidflow.php
urapidflow/v3/run_scheduled.txt · by wtsergo