Observer to modify out of stock add to cart process
I've been looking for a "clean" way to achieve the functionality where I want to add specific logging when a customer tries to add a product to the cart and there's not enough stock to do so - ideally, I add some additional data to the session so that it can be retrieved on the frontend and pushed to Analytics. It seems beyond my feeble mind to do it in a way that adheres to best practices, i.e it looks like I have to copy a core file to the local code pool to be able to override it, or do a rewrite.
The solution I've seen which accomplishes more or less what I want to do is here - however, this involves a local override which I'd prefer to avoid if possible. I have provisionally set up an observer on the chekout_cart_add_before event but I can't see how to hook in the required functionality without just replicating what is already in the core checkQuoteItemQty() method.
Is this one of those situations where a local override or rewrite is unavoidable?
public function logStockStatus(Varien_Event_Observer $observer)
$quoteItem = $observer->getItem();
$qty = $quoteItem->getQty();
// Here I don't want to repeat the same logic already in checkQuoteItemQty
'The Error Message'