I need to get the parent configurable product from a simple product, even if the parent product is marked as disabled. I also need to get the status of the configurable product (enabled or disabled).
Right now I’m getting the parent product like this:
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
if (isset($parentIds[0])) {
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
}
This works perfectly unless the configurable product has been disabled, where the $parentIds array is empty. I need to get the configurable product even if it’s disabled, and also determine if the configurable product is enabled/disabled.
Any help would be appreciated!
I’ve done a little digging around, and I can’t seem to reproduce your issue.
When I call getParentIdsByChild() on a simple with a disabled configurable, I still get the parent product ID.
Gives me:
14446 has a status of disabled. I’ve also tried it as in stock and out of stock.
Looking at the actual function on the resource file
I can see that it looks in the table
catalog_product_super_linkwhich doesn’t have any fields for status, and therefore should always return the parent ID, if the product link exists.