Search code examples
magentomagmi

{Magento - Magmi} Save Product Image Import Information to Database/Custom Log File


First of all, Magmi is a great project, all thanks to dweeves.

I am using product Image import successfully, and log information to state/progress.txt However, I need to save the information regarding import of each of the image items to database, with the log messages that Magmi creates. The import process at the moment provides log messages for failed items/process. I have used a basic plugin which helps me save image/sku info to log file using processItemBeforeId and processItemAfterId.

I really don't want to dig too deep into Magmi source, but I need to save information to a custom table.

  • success / failure status - Magmi log messages (if issues)
  • sku / image name / image path
  • timestamp of import of the item to db

Please direct me to a easy, clean and independent (if I may say so) way to achieve this. As I would want to update to latest git versions.


Solution

  • Since you're already building a Magmi plugin, you can simply leverage the Magmi database handlers to import data into your custom tables.

    //Format your SQL
    $sql = "INSERT INTO $this->tablename("your_custom_table") ('column1, column2')
            VALUES (?,?);"
    
    //Setup the column data
    $data = array('value1, value2');
    
    //Insert into Magento database
    $this->insert($sql, $data);
    

    Magmi also has other database handlers, like:

    $this->selectone() //Selects one record in query.
    $this->selectAll() //Selects all records in query.
    $this->delete(); //Deletes records from query.
    ...and more (look through Magmi's plugins to see how each are used).