i´ve got a code like this:
$product_config = new Mage_Catalog_Model_Product_Type_Configurable();
$product_config->setProduct($product_grouped);
$assigned_products = $product_config->getUsedProducts();
So i create a new config, set the product and get all used products.
Here´s my problem: I want to add another product to the "list" of "used Products", so when I save the product later, the new product should also be added as new "configurable option" with a new price.
With Grouped Products it was much easiert, but i can´t find any way to do this also with a configurable product :(
Thanks for Help!
You can use the product configurable type resource model to add a simple product to a configurable, e.g.:
$configurableId = 135;
$simpleId = 91;
$configurableProduct = Mage::getModel('catalog/product')->load($configurableId);
$simples = $configurableProduct->getTypeInstance('configurable', $configurableProduct)
->getUsedProductIds();
$simples[] = $simpleId;
Mage::getResourceModel('catalog/product_type_configurable')
->saveProducts($configurableProduct, $simples);