/**
  * full import workflow for item
  *
  * @param array $item
  *            : attribute values for product indexed by attribute_code
  */
 public function importItem($item)
 {
     $this->handleIgnore($item);
     if (Magmi_StateManager::getState() == "canceled") {
         throw new Exception("MAGMI_RUN_CANCELED");
     }
     // first step
     if (!$this->callPlugins("itemprocessors", "processItemBeforeId", $item)) {
         return false;
     }
     // check if sku has been reset
     if (!isset($item["sku"]) || trim($item["sku"]) == '') {
         $this->log('No sku info found for record #' . $this->_current_row, "error");
         return false;
     }
     // handle "computed" ignored columns
     $this->handleIgnore($item);
     // get Item identifiers in magento
     $itemids = $this->getItemIds($item);
     // extract product id & attribute set id
     $pid = $itemids["pid"];
     $asid = $itemids["asid"];
     $isnew = false;
     if (isset($pid) && $this->mode == "xcreate") {
         $this->log("skipping existing sku:{$item["sku"]} - xcreate mode set", "skip");
         return false;
     }
     if (!isset($pid)) {
         if ($this->mode !== 'update') {
             if (!isset($asid)) {
                 $this->log("cannot create product sku:{$item["sku"]}, no attribute_set defined", "error");
                 return false;
             }
             $pid = $this->createProduct($item, $asid);
             $this->_curitemids["pid"] = $pid;
             $isnew = true;
         } else {
             // mode is update, do nothing
             $this->log("skipping unknown sku:{$item["sku"]} - update mode set", "skip");
             return false;
         }
     } else {
         $this->updateProduct($item, $pid);
     }
     try {
         $basemeta = array("product_id" => $pid, "new" => $isnew, "same" => $this->_same, "asid" => $asid);
         $fullmeta = array_merge($basemeta, $itemids);
         if (!$this->callPlugins("itemprocessors", "processItemAfterId", $item, $fullmeta)) {
             return false;
         }
         if (count($item) == 0) {
             return true;
         }
         // handle "computed" ignored columns from afterImport
         $this->handleIgnore($item);
         if (!$this->checkstore($item, $pid, $isnew)) {
             $this->log("invalid store value, skipping item sku:" . $item["sku"]);
             return false;
         }
         // if column list has been modified by callback, update attribute info cache.
         $this->initAttrInfos(array_keys($item));
         // create new ones
         $attrmap = $this->attrbytype;
         do {
             $attrmap = $this->createAttributes($pid, $item, $attrmap, $isnew, $itemids);
         } while (count($attrmap) > 0);
         if (!testempty($item, "category_ids") || isset($item["category_reset"]) && $item["category_reset"] == 1) {
             // assign categories
             $this->assignCategories($pid, $item);
         }
         // update websites if column is set
         if (isset($item["websites"]) || $isnew) {
             $this->updateWebSites($pid, $item);
         }
         if (!$this->_same) {
             // update stock
             $this->updateStock($pid, $item, $isnew);
         }
         $this->touchProduct($pid);
         // ok,we're done
         if (!$this->callPlugins("itemprocessors", "processItemAfterImport", $item, $fullmeta)) {
             return false;
         }
     } catch (Exception $e) {
         $this->callPlugins(array("itemprocessors"), "processItemException", $item, array("exception" => $e));
         $this->logException($e);
         throw $e;
     }
     return true;
 }
 /**
  * full import workflow for item
  * @param array $item : attribute values for product indexed by attribute_code
  */
 public function importItem($item)
 {
     $this->handleIgnore($item);
     if (Magmi_StateManager::getState() == "canceled") {
         exit;
     }
     //first step
     if (!$this->callPlugins("itemprocessors", "processItemBeforeId", $item)) {
         return false;
     }
     //check if sku has been reset
     if (!isset($item["sku"]) || trim($item["sku"]) == '') {
         $this->log('No sku info found for record #' . $this->_current_row, "error");
         return false;
     }
     //handle "computed" ignored columns
     $this->handleIgnore($item);
     $itemids = $this->getItemIds($item);
     $pid = $itemids["pid"];
     $asid = $itemids["asid"];
     $isnew = false;
     if (isset($pid) && $this->mode == "xcreate") {
         $this->log("skipping existing sku:{$item["sku"]} - xcreate mode set", "skip");
         return false;
     }
     if (!isset($pid)) {
         if ($this->mode !== 'update') {
             if (!isset($asid)) {
                 $this->log("cannot create product sku:{$item["sku"]}, no attribute_set defined", "error");
                 return false;
             }
             $pid = $this->createProduct($item, $asid);
             $this->_curitemids["pid"] = $pid;
             $isnew = true;
         } else {
             //mode is update, do nothing
             $this->log("skipping unknown sku:{$item["sku"]} - update mode set", "skip");
             return false;
         }
     } else {
         $this->updateProduct($item, $pid);
     }
     try {
         if (!$this->callPlugins("itemprocessors", "processItemAfterId", $item, array("product_id" => $pid, "new" => $isnew, "same" => $this->_same, "asid" => $asid))) {
             return false;
         }
         if (count($item) == 0) {
             return true;
         }
         //handle "computed" ignored columns from afterImport
         $this->handleIgnore($item);
         if (!$this->checkstore($item, $pid, $isnew)) {
             $this->log("invalid store value, skipping item sku:" . $item["sku"]);
             return false;
         }
         //create new ones
         $attrmap = $this->attrbytype;
         do {
             $attrmap = $this->createAttributes($pid, $item, $attrmap, $isnew);
         } while (count($attrmap) > 0);
         if (!testempty($item, "category_ids")) {
             //assign categories
             $this->assignCategories($pid, $item);
         }
         //update websites
         if ($this->mode != "update") {
             $this->updateWebSites($pid, $item);
         }
         if (!$this->_same) {
             //update stock
             $this->updateStock($pid, $item, $isnew);
         }
         $this->touchProduct($pid);
         //ok,we're done
         if (!$this->callPlugins("itemprocessors", "processItemAfterImport", $item, array("product_id" => $pid, "new" => $isnew, "same" => $this->_same))) {
             return false;
         }
     } catch (Exception $e) {
         $this->callPlugins(array("itemprocessors"), "processItemException", $item, array("exception" => $e));
         $this->logException($e, $this->_laststmt->queryString);
         throw $e;
     }
     return true;
 }