我有大約50,000條記錄要在Magento商店中導入。我已經測試過的: 該文件大約爲50 MB。如何使用直接連接到數據庫來導入Magento中的產品
- 劈裂文件
- API
- Magento的類
分割文件不提高產品的進口速度。 Api非常慢。 Magento類很慢。
這是使用Magento的類的代碼文檔片斷:
// Build the product
$product->setIsMassupdate(true)
->setExcludeUrlRewrite(true)
->setManufacturer($this->addManufacturers(utf8_encode($record[4])))
->setSku($record[3])
->setAttributeSetId($this->attribute_set)# 9 is for default
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
->setName(utf8_encode($record[5]))
->setCategoryIds($this->getCategories(array($record[0], $record[1], $record[2]))) # some cat id's,
->setWebsiteIDs(array(1)) # Website id, 1 is default
->setDescription(utf8_encode($record[6]))
->setShortDescription($this->shortText(utf8_encode($record[6]), 150))
->setPrice($price) # Set some price
->setSpecialPrice($special_price)
->setWeight($record[12])
->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setTaxClassId(2) // default tax class
->setPixmaniaimg($record[10])
->setStockData(array('is_in_stock' => $inStock, 'qty' => $qty))
->setCreatedAt(strtotime('now'));
$product->save();
$ID = is_numeric($productID) ? $productID : $product->getId();
所以上面的方法是正確的,但它花費約5小時,以便插入只有2300條記錄!
哪些是我必須在Magento數據庫中執行以添加新產品的簡單SQL插入?
嗨。你終於完成了如何直接導入到數據庫? – Sol 2015-11-17 09:29:28
Hi @Sol yes!我爲我的公司創建了一個模塊,通過對數據庫的直接查詢保存所有數據,但不幸的是我無法共享它。 – Michelangelo 2015-11-17 10:09:24
不錯 - 是不是很辛苦?我想知道開發這種模塊需要多少時間和精力。你能不能簡短地描述它是做什麼的? – Sol 2015-11-17 12:22:21