Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8022: Uncaught Error: Call to a member function addItem() on array in app/code/Magento/Sales/Model/Order/Shipment.php(backport to 2.2) #12173

Merged
merged 1 commit into from
Nov 13, 2017

Conversation

RomaKis
Copy link
Contributor

@RomaKis RomaKis commented Nov 10, 2017

Description

Backport from #11680.
Method getTracksCollection() was able to return different types of data: collection or array. Now it will always return tracks collection object.

Fixed Issues (if relevant)

  1. Uncaught Error: Call to a member function addItem() on array in app/code/Magento/Sales/Model/Order/Shipment.php #8022: Uncaught Error: Call to a member function addItem() on array in app/code/Magento/Sales/Model/Order/Shipment.php

Manual testing scenarios

  1. Load or create a Shipment model
/*** @var $shipment \Magento\Sales\Model\Order\Shipment **/
$shipmentCollection = $this->_objectManager->get(
    'Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory'
)->create();
$shipment = $shipmentCollection->getFirstItem();
{code}
		
2. Make a call
`$shipment->getTracks();`
		
3. Create a Track model and try to add it to the Shipment

{code}
/*** @var $track \Magento\Sales\Model\Order\Shipment\Track **/
$track = $this->_objectManager->get(
    'Magento\Sales\Model\Order\Shipment\TrackFactory'
)->create();
$track->setNumber('Test Number')
          ->setTitle('Test Title')
          ->setCarrierCode('Test CODE');

$shipment->addTrack($track)->save();

Expected result

  1. Successfull save

Actual result

You will receive an error Call to a member function addItem() on array because the method getTracksCollection() in Shipment model will return an array instead of Collection Object.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

… app/code/Magento/Sales/Model/Order/Shipment.php(backport to 2.2)
@magento-engcom-team magento-engcom-team added bugfix Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Sales SQUASHTOBERFEST labels Nov 10, 2017
@ishakhsuvarov ishakhsuvarov self-assigned this Nov 10, 2017
@ishakhsuvarov ishakhsuvarov added this to the November 2017 milestone Nov 10, 2017
@okorshenko okorshenko merged commit 52dff0b into magento:2.2-develop Nov 13, 2017
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
…m() on array in app/code/Magento/Sales/Model/Order/Shipment.php(backport to 2.2) #12173
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Component: Sales Fixed in 2.2.x The issue has been fixed in 2.2 release line Progress: accept Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants