Magento – Are there any csv import logs kept

csvimportexportlogproduct

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

Best Answer

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;
}
Related Topic