3

We've been trying to import a csv of products on to our Magento store, Magento doesn't show any errors when it checks the file, and it reports the import as successful once it has "finished".

The products aren't anywhere to be found though, not on the frontend, nor in our catalog in the backend. I've compared the settings in the csv to those on working products they should have been identical to and these are all right, so there's no reason for them to not be uploaded. Are there any logs kept for imports, or a way to enable such logs, so that we can see what Magento is trying to do with each product in the csv, and hopefully find out why they aren't being uploaded.

Thanks

  • 1
    Which Importer Are you using. DataFlow / ImportExport? – SH- Oct 7 '13 at 23:43
  • We've been using the import/export functions, being new to Magento we haven't used the Dataflow yet. – homespace direct Oct 8 '13 at 8:25
  • ImportExport is pretty good about checking for errors. So, if you are not getting any errors, then something simple is probably wrong ( Or very Subtle). Can you post a small sample of the .csv (Header + a few rows) – SH- Oct 8 '13 at 17:51
  • As far as I know the error 'log' for import export are pre_import. During the Validate Step. ( FYI Enterprise has scheduled ImportExport which will send you and email with validation errors) – SH- Oct 8 '13 at 17:52
4

If you look at the file Mage_ImportExport_Model_Abstract you will see that it has a method addLogComment. Now what this does is add log information at some time during the import and export process, as to when I am not sure.

It will log to files in the format var/log/import_export/%Y/%m/%d/%time%_%operation_type%_%entity_type%.log

There is a flag $_debugMode which you will need to set to activate this logging.

The function looks as follows.

/**
 * Log debug data to file.
 * Log file dir: var/log/import_export/%Y/%m/%d/%time%_%operation_type%_%entity_type%.log
 *
 * @param mixed $debugData
 * @return Mage_ImportExport_Model_Abstract
 */
public function addLogComment($debugData)
{
    if (is_array($debugData)) {
        $this->_logTrace = array_merge($this->_logTrace, $debugData);
    } else {
        $this->_logTrace[] = $debugData;
    }
    if (!$this->_debugMode) {
        return $this;
    }

    if (!$this->_logInstance) {
        $dirName  = date('Y' . DS .'m' . DS .'d' . DS);
        $fileName = join('_', array(
            str_replace(':', '-', $this->getRunAt()),
            $this->getScheduledOperationId(),
            $this->getOperationType(),
            $this->getEntity()
        ));
        $dirPath = Mage::getBaseDir('var') . DS . self::LOG_DIRECTORY
            . $dirName;
        if (!is_dir($dirPath)) {
            mkdir($dirPath, 0777, true);
        }
        $fileName = substr(strstr(self::LOG_DIRECTORY, DS), 1)
            . $dirName . $fileName . '.log';
        $this->_logInstance = Mage::getModel('core/log_adapter', $fileName)
            ->setFilterDataKeys($this->_debugReplacePrivateDataKeys);
    }
    $this->_logInstance->log($debugData);
    return $this;
}
  • I think this works only with scheduled import export docs.magento.com/m1/ee/user_guide/store-operations/… – Mukesh Jan 3 '17 at 10:26
  • 1
    The function is called in both scheduled and none. See app/code/core/Mage/ImportExport/Model/Import.php and it will call this function. – David Manners Jan 3 '17 at 10:36
  • Ok, got it, you are right. But does it create log only when errors occur or we can use it to log information in normal way? – Mukesh Jan 3 '17 at 10:39
  • Should do everytime if it has file permissions – David Manners Jan 3 '17 at 10:50
  • When I set protected $_debugMode = true; and try to run import I get an error Entity is unknown. – Mukesh Jan 3 '17 at 10:55
2

I tried setting $_debugMode = true in the Mage_ImportExport_Model_Abstract model but it didn't create any logs in my case. I was uploading products using DataFlow method.

Then what I did was to change the Mage_Adminhtml_System_Convert_ProfileController a litte bit. Inside batchRunAction() it generates the errors as

try { $importData = $batchImportModel->getBatchData(); $adapter->saveRow($importData); } catch (Exception $e) { $errors[] = $e->getMessage(); continue; }

I logged the $errors array along with the current product sku to get what I needed, i.e., Mage::log($importData['sku'].' - '.$e->getMessage())

0

There are no logs as far as I am aware, but if you use Magmi for your product imports it will create errors on the import screen there.

  • Would it check for errors Magento doesn't throw itself? As far as Magento is concerned everything was imported successfully. – homespace direct Oct 8 '13 at 11:06
  • Yeah it would generally. Magmi would generally not import if there was errors. You can see a full log as well. Details here of how it works: sourceforge.net/apps/mediawiki/magmi/… – MagentoMac Oct 8 '13 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.