There do exist many questions about product attributes in order items. I hope my question has a new aspect.
If I have an order item I can use Mage_Sales_Model_Order_Item::getProduct
to get the product:
public function getProduct()
{
if (!$this->getData('product')) {
$product = Mage::getModel('catalog/product')->load($this->getProductId());
$this->setProduct($product);
}
return $this->getData('product');
}
When we use Mage::getModel('catalog/product')->load($id)
we have access to all product attributes and since the getProduct()
method makes use of it I was quite surprised to see that I did not get all product attributes from this:
foreach( $order->getAllItems() as $item ){
$product = $item->getProduct();
Mage::log($product->debug());
}
My question is: Which part is responsible for setting the product data to an order item?
And how can I extend it? My goal is to get the value of a custom boolean product attribute from an order in an observer after the order has been placed.
In the meantime I found the answer I was looking for (see answer below). But if someone can explain to me why it is not sufficient to clear the cache but instead rebuild the index as well, I will gladly accept this as the answer. It seems the info from the config.xml are written to an index table. Which table and what process is this?