2

I am running a Magento CE 1.8.1.0 - This question is about Magento, and no third party modules.

All the products on my site are configurables. At times I would oversell some products. Investigating these orders led me to the quote object.

For all of the orders which I have oversold I can see a quote, but I see no quote items in the sales_flat_quote_items table. Why is this so?

Also looking at the sales_flat_order_items table, I see, for these orders no simple entries, only configurables.

I wrote a simple sql to lookup quotes that have no quote items, and there seem to be a lot. Why is this so?

SELECT COUNT(DISTINCT increment_id) FROM db.sales_flat_order sfo 
LEFT JOIN db.sales_flat_quote_item sfqi
ON sfo.quote_id = sfqi.quote_id
WHERE sfqi.quote_id IS NULL;

UPDATE: I have manage to reproduce the issue to a degree.

STEPS TO REPRODUCE. Add a config product to the cart, check the sales_flat_quote_items table, see 2 rows (config+simple) - delete the simple row leaving only the config. Order get's placed successfull no stock is deducted from the simple

I think this is what is happening to me - will investigate further but I think this could happen in stock magento stores with high volume traffic because there doesn't seem to be a check on this

For the record, my site regularly sees con-currents of 3000+

6
  • So you are selling products that have no stock in Magento at the time of placing the order? Are you using any 3th party modules in the shop? Commented Mar 17, 2015 at 15:17
  • Yes. Magento is set to deduct stock at checkout, but I am selling more stock than what I have. I have installed a stock movements module, bubbleshop.net/magento-stock-movements.html and it shows stock movement on the config product, which is what I am thinking why I am overselling. It is this investigation that lead me further down the magento rabit hole :) and that lead me to ask my question Commented Mar 17, 2015 at 16:48
  • Did you reach out to Bubble code / Johan Reinke with this issue? He knows the code of the module and can help you with the issue Commented Mar 17, 2015 at 16:50
  • I feel like we are going down the wrong track here. Did you read the question? I used the stock movement module to help me track down the bug, which is what I explained very clearly in my original question. Commented Mar 17, 2015 at 16:55
  • Ahh ok, my mistake. I thought it caused the issue. It wasn't too clear. Commented Mar 17, 2015 at 16:59

2 Answers 2

1

Like you spelled it out, you manually delete a record from the database. Because there is no relation with the sold simple product, it will not update the stock.

I've took a look at the code, you've ajaxDeleteAction for the minicart and deleteAction for the cart to remove items, it is given a quote_item_id.

$quote->removeItem($itemId)

/**
 * Remove quote item by item identifier
 *
 * @param   int $itemId
 * @return  Mage_Sales_Model_Quote
 */
public function removeItem($itemId)
{
    $item = $this->getItemById($itemId);

    if ($item) {
        $item->setQuote($this);
        /**
         * If we remove item from quote - we can't use multishipping mode
         */
        $this->setIsMultiShipping(false);
        $item->isDeleted(true);
        if ($item->getHasChildren()) {
            foreach ($item->getChildren() as $child) {
                $child->isDeleted(true);
            }
        }

        $parent = $item->getParentItem();
        if ($parent) {
            $parent->isDeleted(true);
        }

        Mage::dispatchEvent('sales_quote_remove_item', array('quote_item' => $item));
    }

    return $this;
}

It looks at both, if it has a parent or if it has children.

Bottom line, still think some custom code is messing up things.

0

We managed to reproduce, and fix this issue. It's detailed in a PR to openmage here: https://github.com/OpenMage/magento-lts/issues/364

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.