/** * Update product * * @param Mage_Catalog_Model_Product $magentoProduct Magento product * @param Nicovogelaar_Nedisimport_Model_Entity_Product $product Product * * @return void */ protected function updateProduct(Mage_Catalog_Model_Product $magentoProduct, Nicovogelaar_Nedisimport_Model_Entity_Product $product) { $categoryIds = $magentoProduct->getCategoryIds(); $newCategoryIds = $this->createCategories($product->getCategories()); $categoryIds = array_unique(array_merge($categoryIds, $newCategoryIds)); $magentoProduct->setUpdatedAt(strtotime('now'))->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setSku($product->getSku())->setName($product->getName())->setMsrp($product->getMsrp())->setDescription($product->getDescription())->setShortDescription($product->getShortDescription())->setCategoryIds($categoryIds); $stockItem = $magentoProduct->getStockItem(); if ($stockItem) { $stockItem->setQty($product->getStockQty()); $stockItem->setIsInStock($product->getIsInStock()); } else { $this->createStockItem($magentoProduct, $product); } $this->save($magentoProduct); }