1

I'm programmatically adding products to Magento. I also have a dynamic array (for example: $skuForConfig = array(123, 124))

I use this to add them:

$productData = array();
foreach($skusForConfig as $skuForConfig){
    $productDataTemp = array(
         $skuForConfig => array('0' => array('attribute_id' => '1016', 'label' => 'Size','value_index' => '28563', 'is_percent' => 0, 'pricing_value' => ''))
    );
    array_push($productData, $productDataTemp);
}
$product->setConfigurableProductsData($productData);

So this is the 'dynamic' form for:

    $productData = array(
         '123' => array('0' => array('attribute_id' => '1016', 'label' => 'Size','value_index' => '28563', 'is_percent' => 0, 'pricing_value' => '')),
         '124' => array('0' => array('attribute_id' => '1016', 'label' => 'Size','value_index' => '28563', 'is_percent' => 0, 'pricing_value' => ''))
    );
$product->setConfigurableProductsData($productData);

But... it doesn't work :-(

4

Owww, ofcourse, found it... (I leave it on stackexchange though for people who need to know this too...)

$productData = array();
foreach($skusForConfig as $skuForConfig){
    $productData[$skuForConfig] = array('0' => array('attribute_id' => '1016', 'label' => 'Size','value_index' => '28563', 'is_percent' => 0, 'pricing_value' => ''));
}
$product->setConfigurableProductsData($productData);
  • Yes I will, have to wait another day though ;-) – Bob van Luijt Aug 4 '13 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.