Magento – Assign several simple products at once

import

I'm using https://github.com/avstudnitz/AvS_FastSimpleImport extension to create new simple products programmatically and then assign them to existing configurable product. Problem is I can assign single SKU but can't assign several at once with error "Product with specified super products SKU not found"

<?php

// Trying to assign several simples at once
// either $simples as comma-separated SKU or an array() doesn't work

$assignProducts[] = array(
    'sku' => $configurableProduct->getSku(),
    '_type' => '',
    '_attribute_set' => '',
    '_super_products_sku' => $simples
);

Is the only way to do it is to pass each SKU separately to Mage::getSingleton('fastsimpleimport/import')->processProductImport()?

Anyone faced this task?

Best Answer

If $simples is an array that's not going to work, you'd need to create several rows:

$assignProducts[] = array(
    'sku' => $configurableProduct->getSku(),
    '_type' => '',
    '_attribute_set' => '',
    '_super_products_sku' => 'sku1'
);
$assignProducts[] = array(
    '_super_products_sku' => 'sku2'
);

There was an issue about this exact same problem yesterday, please have a look at: https://github.com/avstudnitz/AvS_FastSimpleImport/issues/9

Related Topic