Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

500 error importing with cronjob
 
lijay
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2012-07-04
 

Hi everybody,
I’ m trying to import products with a cronjob. Everything goes fine until I try to import a file with 50+ row:  it returns 500 error after import some row.
I tried to import by Magento backend and it works (1.7.0.2 version), so there are not problems with my import profile or with the csv file.
I run the command

curl -s http://my path/Cron_Import.php/?files=articoli.csv
in cronjob.
The site is hosting on a semi dedicated server.
Any suggestion? How can I find the origin of this problem?
Thank you and sorry for my english smile
Giulia

There is my php.ini:

upload_max_filesize 1000
mysql
.connect_timeout Off
default_socket_timeout 
360
post_max_size 
1000M
session
.gc_maxlifetime 120000
max_input_time 
100000
memory_limit 
1024M
max_execution_time 
180000
zend_extension
=/usr/local/php54/lib/php/extensions/ioncube.so
zend_extension
=/usr/local/php54/lib/php/extensions/ZendOptimizer.so

and the script cron_import.php

<?php
//uncomment when moved to server - to ensure this page is not accessed from anywhere else
//if ($_SERVER['REMOTE_ADDR'] !== '<your server ip address') {
//  die("You are not a cron job!");
//}

require 'app/Mage.php';
//require 'leggi_zip.php';
// wget -O - http://<www.example.com>/Cron_Import.php/?files=3XSEEEE.csv
  
umask(0);

  
//$_SERVER['SERVER_PORT']='443';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);  
 
// Mage::app();

  
$profileId 7//put your profile id here
  
$filename Mage::app()->getRequest()->getParam('files'); // set the filename that is to be imported - file needs to be present in var/import directory  
  
if (!isset($filename))  {
 
die("No file has been set!");
  
}
  $logFileName
$filename.'.log';  
  
$recordCount 0;

  
Mage::log("Import Started",null,$logFileName);  
 
  
$profile Mage::getModel('dataflow/profile');
  
  
$userModel Mage::getModel('admin/user');
  
$userModel->setUserId(0);
  
Mage::getSingleton('admin/session')->setUser($userModel);
  
  if (
$profileId{
    $profile
->load($profileId);
    if (!
$profile->getId()) {
      Mage
::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists');
    
}
  }

  Mage
::register('current_convert_profile'$profile);

  
$profile->run();
  
  
$batchModel Mage::getSingleton('dataflow/batch');
  if (
$batchModel->getId()) {
    
if ($batchModel->getAdapter()) {
      $batchId 
$batchModel->getId(); 
      
$batchImportModel $batchModel->getBatchImportModel();
      
$importIds $batchImportModel->getIdCollection();  
      
$batchModel Mage::getModel('dataflow/batch')->load($batchId);      
      
$adapter Mage::getModel($batchModel->getAdapter());
      foreach (
$importIds as $importId{
        $recordCount
++;
            
ob_flush();
            
flush();
        
try{            

          $batchImportModel
->load($importId);
          if (!
$batchImportModel->getId()) {
             $errors[] 
Mage::helper('dataflow')->__('Skip undefined row');
             continue;
          
}

          $importData 
$batchImportModel->getBatchData();
          try 
{
            $adapter
->saveRow($importData);

          
catch (Exception $e{
            Mage
::log($e->getMessage(),null,$logFileName);          
            continue;
          
}
        
          
if ($recordCount%20 == 0{
            Mage
::log($recordCount ' - Completed!!',null,$logFileName);
          
}
        } 
catch(Exception $ex{
          Mage
::log('Record# ' $recordCount ' - SKU = ' $importData['sku']' - Error - ' $ex->getMessage(),null,$logFileName);        
        
}
      }
      
foreach ($profile->getExceptions() as $e{
        Mage
::log($e->getMessage(),null,$logFileName);          
      
}
      
    }
  }
  
echo 'Import Completed';
  
Mage::log("Import Completed",null,$logFileName);
 
?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top