我正在使用带有扩展程序的 magmi,它从另一家商店/magento 获取数据并使用 magmi 导入产品。一切进展顺利。 但我不知道如何传递属性数据,因为我有“属性标题”、“属性值”和“属性代码”。创建属性的信息是否足够?
代码是:
$incFile = MAGENTO_ROOT . '/magmi/inc/magmi_defs.php';
$dataPumpFileName = MAGENTO_ROOT . '/magmi/integration/inc/magmi_datapump.php';
// end include PATH's
require_once($incFile);
require_once($dataPumpFileName); // call Datapump
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("default","create");
$newProductData = array(
'name' => $value['Symbol'].','.$value['Producer'].','.$value['Description'],
'sku' => $value['Symbol'], // sku
'price' => $value['PriceList'][0]['PriceValue'], // price
'cost' => $value['PriceList'][0]['PriceValue'],
'related_products' => $relResultProducts,
'store' => 'admin',
'description' => $parameterTable, // full description
'short_description' => $value['Description'], // short description
'qty' => $value['Amount'], // qty
'min_sale_qty' => $value['MinAmount'],
'use_config_min_sale_qty' => '0',
'category_ids' => $category_id.',1466', // ID of categories
'visibility' => '4',
'status' => '1',
'weight' => ($value['Weight']/1000), // weight
'tax_class_id' => '2', // tax class id (check your ids)
'manufacturer' => $value['Producer'], // manufacturer
'meta_title' => $value['Symbol'], // meta title
'meta_description' => $value['Description'], // meta description
'meta_keyword' => $value['Symbol'], // meta keywords
'type' => 'simple',
'fme_rule_enable' => '1',
'custom_stock_status_qty_based' => '1',
'tier_price:all' => $tirePrice,
'image_label' => $value['Symbol'].','.$value['Producer'].','.$value['Description'],
'small_image_label' => $value['Symbol'].','.$value['Producer'].','.$value['Description'],
'thumbnail_label' => $value['Symbol'].','.$value['Producer'].','.$value['Description'],
);
$newProductData['image'] = '+http:'.$value['Photo'];
$newProductData['small_image'] = '+http:'.$value['Photo'];
$newProductData['thumbnail'] = '+http:'.$value['Thumbnail'];
$newProductData['media_gallery'] = '+';
foreach($value['ParameterList'] as $ParameterValue){
$attr_code = strtolower($ParameterValue['ParameterName']);
$attr_code = str_replace(' ', '_', $attr_code);
$newProductData[$attr_code] = $ParameterValue['ParameterValue'];
}
Mage::log($newProductData, true);
$dp->ingest($newProductData);
属性代码是主要栏目,具体取决于 Magmi 更新的产品。如果是dropdown类型的属性,magmi会自动创建它的属性标签。