2013-04-24 25 views
0

我試圖用datapump api創建可配置產品。我可以創建簡單的產品。但我不能創建/鏈接可配置產品。這是我的數據數組。我錯過了什麼嗎?Magmi數據泵api與可配置產品

Array(['type'] => 'simple',['sku'] => 'A001-2',['price'] => 10,['color'] => 'Blue',['qty'] => 100,['is_in_stock'] => 1,['name'] => 'A001-2',['tax_class_id'] => 1,['store'] => 'admin',) 

Array(['type'] => 'simple',['sku'] => 'A001-1',['price'] => 10,['color'] => 'Indigo',['qty'] => 100,['is_in_stock'] => 1,['name'] => A001-1,['tax_class_id'] => 1,['store'] => admin,) 

Array(['type'] => 'configurable', ['sku'] => 'A001',['name'] => 'TREAD JEANS',['description'] => 'Latest Edition of gunshot jeans',['price'] => 55.5,['simples_skus'] => 'A001-2,A001-1',['configurable_attributes'] => 'color',['qty'] => 100,['is_in_stock'] => 1,['tax_class_id'] => 1,) 

回答

0

從我所看到的,你缺少強制性的attribute_set數據。嘗試爲您的項目定義一個屬性集並重新導入。

+0

如果我們不設置attribute_set,magmi將作爲「默認」。 – Palanikumar 2013-04-25 05:41:59

0

最後,我自己找到了解決方案。由於即時通訊不使用csv文件導入,我不得不從「plugins.conf」文件中刪除Magmi_CSVDataSource。現在我的數據源是這個樣子

[PLUGINS_DATASOURCES] 
class = "" 

以前它是這樣

[PLUGINS_DATASOURCES] 
class = "Magmi_CSVDataSource" 

這爲我工作。現在我可以使用datapump導入可配置的產品。

0

我看你已經達到修改plugins.conf。你也可以在沒有修改的情況下做到這一點。這裏是一個示例代碼:

<?php 
// assuming that your script file is located in magmi/integration/datapump/product.php, 
// include "magmi_defs.php" , once done, you will be able to use any magmi includes without specific path. 
require_once("../../inc/magmi_defs.php"); 
//Datapump include 
require_once("../inc/magmi_datapump.php"); 

// create a Product import Datapump using Magmi_DatapumpFactory 
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport"); 

$dp->beginImportSession("default","create"); 
$newProductData = array(
    'type'   => 'simple', 
    'sku'   => "A001-2", 
    'qty'   => 1000, 
    'color'   => 'Blue', 
    'price'   => 10, 
    'name'   => 'A001-2', 
    'tax_class_id' => 1, 
    'is_in_stock' => 1, 
    'store'   => 'admin' 
); 
$dp->ingest($newProductData); 

$newProductData = array(
    'type'   => 'simple', 
    'sku'   => "A001-1", 
    'qty'   => 1000, 
    'color'   => 'Indigo', 
    'price'   => 10, 
    'name'   => 'A001-1', 
    'tax_class_id' => 1, 
    'is_in_stock' => 1, 
    'store'   => 'admin' 
); 
$dp->ingest($newProductData); 

$newProductData = array(
    'type'   => 'configurable', 
    'sku'   => "A001", 
    'qty'   => 1000, 
    'price'   => 10, 
    'simples_skus' => 'A001-2,A001-1', 
    'configurable_attributes' => 'color', 
    'name'   => 'TREAD JEANS', 
    'tax_class_id' => 1, 
    'is_in_stock' => 1, 
    'store'   => 'admin' 
); 
$dp->ingest($newProductData); 
$dp->endImportSession(); 
?> 

不要忘記使用magmi UI,使Configurable Item processor