This seems like it should be straightforward but I cannot find a clean solution:
Given an order item, what's the best way to figure out if the item has its own stock?
First I load the stock item:
$stockItem = Mage::getModel('cataloginventory/stock_item')
->loadByProduct($orderItem->getProductId());
Unfortunately, I get results for all items, and those from configurable products seem undistinguishable from simple products.
Then I thought of:
- checking the product type. This is my least favorite solution because we work a lot with custom product types. I would have to define every single case and change it when new types are added
- checking if item is a parent item. Possible but there is only
getParentItem()
so I'd have to go through all items, collect the parent item ids and remove those items.
For a generic solution it would be great to cover virtual products as well but for my use case it is not relevant. Am I missing something obvious?