Magmi Datapump api具有可配置产品

时间:2013-04-24 07:59:02

标签: magento magento-1.7 magmi

我正在尝试使用datapump 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,)

3 个答案:

答案 0 :(得分:0)

从我所看到的,您缺少必需的attribute_set数据。尝试为您的商品定义属性集并重新导入。

答案 1 :(得分:0)

最后我自己找到了解决方案。由于我没有使用csv文件导入,我不得不从“plugins.conf”文件中删除Magmi_CSVDataSource。现在我的数据源看起来像这样

[PLUGINS_DATASOURCES]
class = ""

以前就像这样

[PLUGINS_DATASOURCES]
class = "Magmi_CSVDataSource"

这对我有用。现在我可以使用datapump导入可配置产品。

答案 2 :(得分: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