How do I get the saleable product attributes (attribute values of associated simple products that are enabled, have stock, ...) for a given configurable product?
Thanks in advance
How do I get the saleable product attributes (attribute values of associated simple products that are enabled, have stock, ...) for a given configurable product?
Thanks in advance
You can get the valid simple products associated to a configurable one like this:
$products = array();
$allProducts = $mainProduct->getTypeInstance(true)
->getUsedProducts(null, $mainProduct);
foreach ($allProducts as $product) {
if ($product->isSaleable()) {
$products[] = $product;
}
}
and you can get the configurable attributes for the configurable product like this:
$attributes = $mainProduct->getTypeInstance(true)
->getConfigurableAttributes($mainProduct);
in both cases $mainProduct
is the configurable product instance.
Now you can put them all together as you wish. I would have done it but your question is a bit unclear.