4

I've just upgraded magento version from 1.6 to 1.9.1.1. I go to system/configuration/sales/payment methods and got the following error:

wrong content type

I have tried to debug by going to this function on app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php:

public function getAllowedMethods()
    {
        $contentType = $this->getConfigData('content_type');
        $allowedMethods = array();
        if ($this->_isDomestic) {
            $allowedMethods = array_merge(explode(',', $this->getConfigData('doc_methods')),
                explode(',', $this->getConfigData('nondoc_methods'))
            );
        } else {
            switch ($contentType) {
                case self::DHL_CONTENT_TYPE_DOC:
                    $allowedMethods = explode(',', $this->getConfigData('doc_methods'));
                    break;
                case self::DHL_CONTENT_TYPE_NON_DOC:
                    $allowedMethods = explode(',', $this->getConfigData('nondoc_methods'));
                    break;
                default:
                    Mage::throwException(Mage::helper('usa')->__('Wrong Content Type.'));
            }
        }
        $methods = array();
        foreach ($allowedMethods as $method) {
            $methods[$method] = $this->getDhlProductTitle($method);
        }
        return $methods;
    } 

I tried to var_dump($contentType) add get NULL value. What's wrong here ?

UPDATE:

My Content Type config in admin panel:

content type DHL

2 Answers 2

5

As you may have noticed in the given source code, the exception is thrown because null is not an allowed value for $contentType. $contentType is read from the system configuration:

$contentType = $this->getConfigData('content_type');

It is as simple as changing the system configuration setting to one of the allowed values. This can be done for instance via Admin Panel

System → Configuration → Sales → Shipping Methods → DHL → Content Type

or by adding a valid core_config_data entry for the config path carriers/dhlint/content_type.

3
  • I have already choosen content type in admin panel but still getting error.
    – HungDQ
    Commented Jul 10, 2015 at 9:17
  • This is a dropdown with only two non-empty options. So even if no value is stored to the database it will display Documents there. Please make sure the value is actually set in the database and the config cache is refreshed.
    – mam08ixo
    Commented Jul 10, 2015 at 9:22
  • You're right. I've tried to save this setting again and it works. I really appreciate your help.
    – HungDQ
    Commented Jul 10, 2015 at 9:30
1

I also get the same problem and resolved with following: Goto app > code > core > Mage > Usa > etc > Config.xml Add Below code at <carriers> <dhlint> :

<content_type>D</content_type>
1
  • Please, if you have answer, write here. Don't give just links Commented Apr 1, 2016 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.