Magento 2.0 Bug in Core Sales Module

magento-2-bug

As we all know Magento 2.0 is out since November last year. Though this new version has some amazing enhancements over its previous 1.9 series it has still has some bugs. Magento team is working on fixing these issues as well, but some of our customers have already upgraded to Magento 2.0, so we had to provide a fix immediately to prevent any integration problem.

ISSUE:-

When we are pulling sales order data using REST Api,in the address section, we are getting the value ofย region_code as region name which should not be the case but it should have the value of region_code itself.

SOLUTION:-

For this we need to change the core files to get the things correct.

Follow the below path to make the changes:-

[magento_root_folder]
Vendor
module-sales
Model
Order
Open Address.php file and comment out line no 125,126 and 127
This particular code in the function public function getRegionCode()
if (is_string($this->getRegion())) {
return $this->getRegion();
} 

EXPLANATION FOR REMOVAL :

Whenever it gets the region name, it returns the value from there only. As a result, we get the region name as the value of region_code. So on removing this part it will not trigger getRegion() function and as a result, we will not get the region name in region_code.

  • abhi2434

    Good stuff. It seems magento made a lame mistake on the file. Kudos Arijit to find the problem.

    • Arijit De

      Thanks! @abhi2434:disqus . Many to come ๐Ÿ™‚ Hope, it gets identified by the Magento team ๐Ÿ™‚

  • Bravo. can’t we extend this class, so that we can easily fork and merge to our repo ? @disqus_0Q4SyX9qgU

    • abhi2434

      Thats a case we will try for sure. But we proposed the bug to Magento… lets hope the next release has an update.