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 #11680

Merged
merged 3 commits into from
Nov 12, 2017

Conversation

RomaKis
Copy link
Contributor

@RomaKis RomaKis commented Oct 24, 2017

Description

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)

@ishakhsuvarov ishakhsuvarov self-assigned this Oct 24, 2017
@ishakhsuvarov ishakhsuvarov added this to the October 2017 milestone Oct 24, 2017
@ishakhsuvarov ishakhsuvarov added Release Line: 2.3 2.2.x bug report 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 labels Oct 24, 2017
… app/code/Magento/Sales/Model/Order/Shipment.php
… app/code/Magento/Sales/Model/Order/Shipment.php
@okorshenko okorshenko modified the milestones: October 2017, November 2017 Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report bugfix Component: Sales Progress: accept Release Line: 2.3 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