Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:30:31+00:00 2026-06-04T01:30:31+00:00

I’ve been looking over Magento’s code (1.6.2 Community Edition), and OMG is it a

  • 0

I’ve been looking over Magento’s code (1.6.2 Community Edition), and OMG is it a terribly executed mess, but I won’t rant here about that.

Looking at this code:

// Delete error from item and its quote, if it was set due to qty lack
$this->_removeErrorsFromQuoteAndItem($quoteItem, Mage_CatalogInventory_Helper_Data::ERROR_QTY);

Which is in Mage_CatalogInventory_Model_Observer class in
/app/code/core/Mage/CatalogInventory/Model/Observer.php
Line: 489

This produces a peculiar bug to me, try this (make sure “no backorders” is set in backend):

  1. Add a product to the cart
  2. Add another product to the cart.
  3. Go in admin and change first product quantity such that the requested quantity in the cart is not enough.
  4. Go back to shopping cart page.

Result
The first product added shows the “requested item not available in this quantity” error, but the Checkout methods are still shown ! Continuing forward, eventually gives an ugly js alert saying “Not all items are available in the requested qty”.

Digging deeper I see that it seems every quote item (cart item) added to the quote (cart) resets the error state for the whole quote.

Is this intentional ? Have I stumbled upon a genuine bug ?
What does this useless comment mean ?
Thanks in advance.

EDIT: See answer below for workaround and explanation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:30:33+00:00Added an answer on June 4, 2026 at 1:30 am

    I have to post a follow up, My core hack had an unfortunate side effect (another bug):

    1. Add item to cart with certain quantity (make sure it is stock).
    2. Go in admin panel and reduce stock so that the remaining quantity is no longer.
    3. Go back to the cart page and refresh, you get the expected error.
    4. Try to update the cart and reduce the requested quantity to that which is in fact available, you will notice that the update does not work and the error from #3 is redisplayed.

    So apparently this particular logic is necessary for that scenario.

    The actual flaw is that the quote error info collection does not differentiate between quote items. So the _removeErrorsFromQuoteAndItem function removes all quantity related errors from the cart including those that came from another quote item (that is still in error).

    I found a workaround that works without any core hacks, attach this event observer to the sales_quote_item_qty_set_after event.

    public function reinitQuoteErrorState(Varien_Event_Observer $observer)
    {
        $item = $observer->getEvent()->getItem();
        /** @var $item Mage_Sales_Model_Quote_Item */
    
        $quote = $item->getQuote();
        /** @var $quote Mage_Sales_Model_Quote */
    
        // Quote not loaded, do nothing since our changes are transient
        if (!$quote) return;
    
        // Quote already has error state, nothing to do.
        if ($quote->getHasError()) return;
    
        foreach ($quote->getAllItems() as $quoteItem)
        {
            if ($errorItems = $quoteItem->getErrorInfos())
            {
                foreach ($errorItems as $errorItem)
                {
                    if ($errorItem['code'] == Mage_CatalogInventory_Helper_Data::ERROR_QTY)
                    {
                        $quote->addErrorInfo(
                            'error',
                            'cataloginventory',
                            Mage_CatalogInventory_Helper_Data::ERROR_QTY,
                            Mage::helper('cataloginventory')->__('Not all products are available in the requested quantity')
                        );
    
                        return;
                    }
                }
            }
        }
    }
    

    Note: The module that has this event handler must add to the tag of the module XML file in /app/etc/modules/ (eg: /app/etc/modules/MyCompany_MyModule.xml) to ensure that this handler is called after Mage_CatalogInventory_Model_Observer::checkQuoteItemQty which has the bug.

    The real solution is to fix the quote errorInfo system to maintain quote item identity, but this workaround will do without any core hacks.

    <?xml version="1.0" encoding="utf-8"?>
    <config>
        <modules>
            <MyCompany_MyModule>
                <active>true</active>
                <codePool>local</codePool>
                <depends>
                    <Mage_CatalogInventory />
                </depends>
            </MyCompany_MyModule>
        </modules>
    </config>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.