I created an event observer to report the creation of new magento products, but the observer doesn't work when the products are created by importing Magmi.

My magento version is

This is the config.xml


This is the Observer:

class Wally_LogProductUpdate_Model_Observer
    protected $isNew = false;

    public function beforeSave($observer)
        $product = $observer->getEvent()->getProduct();
        if ($product->isObjectNew()) {
            $this->isNew = true;

    public function afterSave($observer)
        $product = $observer->getEvent()->getProduct();
        if ($this->isNew) {
            $name = $product->getName();
            $sku = $product->getSku();
            $price = $product->getPrice();

            Mage::log("[{$name} ({$sku}) {$price}] aggiornato", null, 'product-updates.log');           

Is it the right way or do I have to work in other ways to import products using magmi?


As per official wiki of magmi:

Magmi is a Magento Mass Importer developed as a magento DATABASE client, (ie not a magento extension) , that operates directly in SQL.

So magmi runs raw query and any event will not dispatched during import by magmi!

  • Yes, these days I have read that magmi does not pass by the orm model of magento, so what is the best solution to get the id of new products imported from magmi? – Mastafis Apr 8 '19 at 18:35
  • 1
    You can add additional attribute while import from magmi say is_magmi_new and set value to 1 while import. after import you can create a script on root and check for all product is_magmi_new with value 1. once you done you goal, you can set value to 0 – Pawan Apr 10 '19 at 3:05
  • Good idea, I try to do it :D – Mastafis Apr 10 '19 at 14:02
  • did it worked ? – Pawan Apr 12 '19 at 2:34
  • No @Pawan I was not able to do it this way, in the end I opted to create a custom event and pass everything to an observer who retrieves product ids based on the date of creation – Mastafis Apr 15 '19 at 14:03

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.