Exemplo n.º 1
0
set_time_limit(0);
$mageRoot = dirname(dirname(getcwd()));
require $mageRoot . '/app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
umask(0);
require $mageRoot . '/Vic.php';
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Vikont_Pulliver_Model_Log::setLogFileName('pulliver.log');
Vikont_Pulliver_Helper_Data::setSilentExceptions(true);
Vikont_Pulliver_Helper_Data::inform("\nLightSpeed Convertor started...\n");
$commonHelper = Mage::helper('pulliver');
$moduleHelper = Mage::helper('pulliver/LightSpeed');
try {
    $params = isset($argv) ? Vikont_Pulliver_Helper_Data::getCommandLineParams($argv) : new Varien_Object($_GET);
    Mage::register('pulliver_params', $params);
    foreach (Vikont_Pulliver_Helper_LightSpeed::getVendors() as $vendorIndex => $vendor) {
        if ($downloadedFileName = $params->getData('file_' . $vendor)) {
            Vikont_Pulliver_Helper_Data::inform(sprintf('Skipped downloading, using local file %s', $downloadedFileName));
            $data = $moduleHelper->decodeFile($downloadedFileName);
        } else {
            $data = $moduleHelper->decodeJson($moduleHelper->downloadVendorRepository($vendor));
        }
        if ($data) {
            Vikont_Pulliver_Helper_Data::inform('data decoded successfully for vendor: ' . $vendor);
        } else {
            Vikont_Pulliver_Helper_Data::inform('could not decode inventory from vendor: ' . $vendor);
            continue;
        }
        // file stuff
        $fileName = $moduleHelper->getLocalFileName('lightspeed-' . $vendor . '.csv');
        $fileHandle = $commonHelper->openFile($fileName);
Exemplo n.º 2
0
$mageRoot = dirname(dirname(getcwd()));
require $mageRoot . '/Vic.php';
require $mageRoot . '/app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
umask(0);
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Vikont_Pulliver_Model_Log::setLogFileName('pulliver.log');
Vikont_Pulliver_Helper_Data::setSilentExceptions(true);
Vikont_Pulliver_Helper_Data::inform("\nLightSpeed Convertor started...\n");
$commonHelper = Mage::helper('pulliver');
$moduleHelper = Mage::helper('pulliver/LightSpeed');
$skuHelper = Mage::helper('pulliver/Sku');
try {
    $params = isset($argv) ? Vikont_Pulliver_Helper_Data::getCommandLineParams($argv) : new Varien_Object($_GET);
    Mage::register('pulliver_params', $params);
    $vendors = $params->getData('vendor') ? explode(',', $params->getVendor()) : Vikont_Pulliver_Helper_LightSpeed::getVendors();
    foreach ($vendors as $vendorIndex => $vendor) {
        $isWarehouse = 'warehouse' == $vendor;
        if ($downloadedFileName = $params->getData('file-' . $vendor)) {
            Vikont_Pulliver_Helper_Data::inform(sprintf('Skipped downloading, using local file %s', $downloadedFileName));
            Vikont_Pulliver_Helper_Data::inform('Decoding data for vendor: ' . $vendor);
            $data = $moduleHelper->decodeFile($downloadedFileName);
        } else {
            $data = $moduleHelper->decodeJson($moduleHelper->downloadVendorRepository($vendor));
            Vikont_Pulliver_Helper_Data::inform('Decoding data for vendor: ' . $vendor);
        }
        if ($data) {
            if (isset($data['Message']) && $data['Message']) {
                Vikont_Pulliver_Helper_Data::inform(sprintf("ERROR getting data, error message:\n%s\n%s", $data['Message'], @$data['MessageDetail']));
                break;
            }