magento - Magmi import update option -


does magmi has option disable or make quantity 0 products not in csv file in import?. because supplier remove out of stock products csv file. if can me on or finding solution please. thank in advance

i've created plugin disables files not in csv. prefer disabling items, instead of deleting them in case goes wrong (it won't wipe database).

  1. create plugin file magmi/plugins/extra/general/itemdisabler/magmi_itemdisabler_plugin.php

  2. in file, paste in following , save:

plugin code:

<?php class magmi_itemdisablerplugin extends magmi_itemprocessor {     protected $datasource_skus = array();          public function getplugininfo()     {         return array("name"=>"magmi magento item disabler",                              "author"=>"axel norvell (axelnorvell.com)",                              "version"=>"1.0.6");     }            public function afterimport()     {         $this->log("running item disabler plugin","info");         $this->disableitems();         return true;     }      public function getpluginparams($params)     {         return array();     }      public function isrunnable()     {         return array(true,"");     }      public function initialize($params)     {     }      public function processitemafterid(&$item,$params=null)     {         if(isset($item['sku']))         {             $this->datasource_skus[] = $item['sku'];         }     }      public function disableitems()     {         if(count($this->datasource_skus) <= 0)         {             $this->log('no items found in datasource.  item disabler not run.', "info");             return false; /* nothing disable */           }          //setup tables         $ea     = $prefix!=""?$prefix."eav_attribute":"eav_attribute";         $eet     = $prefix!=""?$prefix."eav_entity_type":"eav_entity_type";         $cpe     = $prefix!=""?$prefix."catalog_product_entity":"catalog_product_entity";         $cpei     = $prefix!=""?$prefix."catalog_product_entity_int":"catalog_product_entity_int";          //get "status" attribute_id         $status_attr_id = "                  select ea.attribute_id $ea ea             left join $eet eet on ea.entity_type_id = eet.entity_type_id             ea.attribute_code = 'status'             , eet.entity_type_code = 'catalog_product'";                        $result = $this->selectall($status_attr_id);           if (count($result) == 1) {             $attribute_id = $result[0]['attribute_id'];         }         unset($result);          //get active items         $sql = "select e.sku, e.entity_id $cpei                           inner join $cpe e on                           e.entity_id = i.entity_id                           attribute_id=?                           , i.value = 1";         $all_magento_items = $this->selectall($sql, array($attribute_id));          //setup magento_skus array easy processing.         $magento_skus = array();         foreach($all_magento_items $item)         {             $this->log("{$item['sku']} found in mage", "info");              $magento_skus[$item['sku']] = $item['entity_id'];         }           //process array, move thats in datasource.         foreach($this->datasource_skus $sku)         {             if(isset($magento_skus[$sku]))             {                 unset($magento_skus[$sku]);             }         }          if(!empty($magento_skus))         {                            foreach($magento_skus $sku => $id)             {                  $this->log("disabling item id $id sku: $sku", "info");                  $this->update("                     update $cpei                     inner join $cpe e on                     e.entity_id = i.entity_id                     set value = '2'                     attribute_id = ?                     , i.value = 1                     , e.sku=?", array($attribute_id, $sku));             }         }         else         {             //if datasource contains magento's items.             $this->log('all items present in datasource.  no items disable.', "info");                }      } } 

then login magmi, enable plugin , run import. plugin execute after import has completed. opens datasource, logs of skus, compares them against magento database. skus aren't found in datasource disabled. plugin optimized bit better works right now.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -