shipperhq / module-shipper

Base ShipperHQ Repo
Open Software License 3.0
21 stars 21 forks source link

500 Error if the items on request don't have index 0 defined #68

Closed duckchip closed 4 years ago

duckchip commented 5 years ago

Hi guys,

We're having an issue when the items of a request don't have an index zero defined.

Magento v2.1.16 ShipperHQ v20.27.0

In class src/Model/Carrier/Processor/ShipperMapper.php function getCustomerGroupId

public function getCustomerGroupId($items)
    {
       if (!empty($items)) {
            return $items[0]->getQuote()->getCustomerGroupId();
        }
        return null;
    }

I resolved the issue by changing the functionality to this:

public function getCustomerGroupId($items)
    {
        if (!empty($items)) {
            $item = reset($items);
            return $item->getQuote()->getCustomerGroupId();
        }
        return null;
    }

This is a bit saver, still not perfect, but it fixes my issue.

Would it be possible to change this in the core?

Stack trace in attachment shipperhq-issue-68.txt

wsajosh commented 4 years ago

Hey @duckchip

Thanks for raising this! Its not something I've seen before and shouldn't really happen. Can you provide some details on how to replicate this please?

I'll work on getting a fix in to avoid this in future. I'm assuming if it has to wait a couple of weeks that it won't be a issue as you've already fixed it on your site, please let me know if that's not the case

wsajosh commented 4 years ago

@duckchip Thanks for raising this. The fix is in the latest release. I've modified the proposed fix slightly