Magento2: getTracking() not found in 2.3.3

Created on 6 Mar 2020  路  2Comments  路  Source: magento/magento2

I am getting the error :

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\Phrase::getTracking() in /domains/XX/http/vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml:21 Stack trace: #0

On the customer "track order" (through the back end also) which is the popup.html in in module-shipping.

I have seen the magento github it was apperently fixed by 2.2 but i'm on 2.3.3 and i'm getting the issue.

ready for confirmation Reported on 2.3.3

Most helpful comment

The problem is in \Magento\ShippingModel\Order\Track::getNumberDetail. If a carrier instance can be loaded, the logic assumes it will have a getTrackingInfo method that will return a data object. When it doesn't, a phrase object is returned instead. A phrase object is fundamentally incompatible with Magento_Shipping::tracking/details.phtml.

When a carrier instance doesn't return tracking info, it should fall back to the same behavior it uses when there is no carrier instance: return an array containing the title and tracking number.

I recommend getNumberDetail be updated to this:

`
$carrierInstance = $this->_carrierFactory->create($this->getCarrierCode());
if ($carrierInstance) {
$carrierInstance->setStore($this->getStore());
$carrierInfo = $carrierInstance->getTrackingInfo($this->getNumber());
if ($carrierInfo) {
return $carrierInfo;
}
}

$trackingInfo = [];
$trackingInfo['title'] = $this->getTitle();
$trackingInfo['number'] = $this->getTrackNumber();
return $trackingInfo;

`

All 2 comments

Hi @gazsmith10. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@gazsmith10 do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

The problem is in \Magento\ShippingModel\Order\Track::getNumberDetail. If a carrier instance can be loaded, the logic assumes it will have a getTrackingInfo method that will return a data object. When it doesn't, a phrase object is returned instead. A phrase object is fundamentally incompatible with Magento_Shipping::tracking/details.phtml.

When a carrier instance doesn't return tracking info, it should fall back to the same behavior it uses when there is no carrier instance: return an array containing the title and tracking number.

I recommend getNumberDetail be updated to this:

`
$carrierInstance = $this->_carrierFactory->create($this->getCarrierCode());
if ($carrierInstance) {
$carrierInstance->setStore($this->getStore());
$carrierInfo = $carrierInstance->getTrackingInfo($this->getNumber());
if ($carrierInfo) {
return $carrierInfo;
}
}

$trackingInfo = [];
$trackingInfo['title'] = $this->getTitle();
$trackingInfo['number'] = $this->getTrackNumber();
return $trackingInfo;

`

Was this page helpful?
0 / 5 - 0 ratings