Skip to content

updateQuoteItems reports error missing qty @ Undefined index: qty in Sales/Order/CreateController.php #1187

Open
@seansan

Description

@seansan

We are seeing some error statements like 2020-09-07T07:38:47+00:00 ERR (3): Notice: Undefined index: qty in app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php on line 850

the qty variable is not present in the $data object, the error is created here https://github.com/OpenMage/magento-lts/blob/1.9.4.x/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php#L850

I guess only a couple of causes can exist?

  • the CreateController action is triggered by post data containing update_items but missing qty param?
  • qty param logic in updateQuoteItems is flawed and if empty should be 0 or maybe the function should return immediately because there is not qty to update to ...
  • the CreateController action update_items should no longer used?

Only location where "updateQuoteItems" is mentioned app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php


        /**
         * Update quote items
         */
        if ($this->getRequest()->getPost('update_items')) {
            $items = $this->getRequest()->getPost('item', array());
            $items = $this->_processFiles($items);
            $this->_getOrderCreateModel()->updateQuoteItems($items);
        }

Preconditions (*)

  1. php 7.2 LTS 20.x

Steps to reproduce (*)

  1. Not certain, I am adding some logging to identify the route that was accessed and log full request

Expected result (*)

  1. No error

Actual result (*)

  1. 2020-09-07T07:38:47+00:00 ERR (3): Notice: Undefined index: qty in app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php on line 850

A possible fix could be to leave the qty alone?

                        if (array_key_exists('qty', $info)) {
                            $itemQty    = (float)$info['qty'];
                        } else {
                            $itemQty    = $item->getQty();
                        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions