Magento Integration With T-Hub


Magento Integration With T-Hub

正在为与Magento和quickbooks的T-Hub集成设置一个沙盒。 我已经使用 WAMP 服务器在本地设置了我的生活网站,现在它开始尝试将该本地 Magento 网站绑定到 T-hub。 我收到的第一个错误指出

"与Magento商店的连接失败。服务身份验证失败 - 注意:未定义的索引:httponly 在 c:''wamp''www''testsite''appcode''core''mage''Core''Model''Session''Abtract''Varien.php 在第 98 行。

经过一番搜索,我发现关于这个问题的普遍共识是我必须在本地服务器上放置一个 ssl,完成,这个问题已经消失了。现在我收到一条一般错误消息,只是说

"与Magento的连接失败"

我使用了atandra包含在他们的文件中的测试页面,该页面返回了以下内容:

<RESPONSE Version="4.1">
<Envelope>
<Command>GETORDERS</Command>
<StatusCode>9001</StatusCode>
<StatusMessage>
 Service authentication failure - Warning: array_key_exists() expects parameter 2 to be array,      string given in C:'wamp'www'adamsarms'app'code'core'Mage'Captcha'Model'Observer.php on line 166
</StatusMessage>
<Provider>Magento</Provider>
</Envelope>
</RESPONSE>

回到这个是php文件:

public function checkUserLoginBackend($observer)
{
    $formId = 'backend_login';
    $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
    $loginParams = Mage::app()->getRequest()->getPost('login', array());
    $login = array_key_exists('username', $loginParams) ? $loginParams['username'] : null;
    if ($captchaModel->isRequired($login)) {
        if (!$captchaModel->isCorrect($this->_getCaptchaString(Mage::app()->getRequest(), $formId))) {
            $captchaModel->logAttempt($login);
            Mage::throwException(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
        }
    }
    $captchaModel->logAttempt($login);
    return $this;
}

这一行是它直接指向的那一行:

$login = array_key_exists('username', $loginParams) ? $loginParams['username'] : null;

我不确定我需要去哪个方向修复此错误以使 t-hub 开始与 magento 正确交谈,我已经包含了我所拥有的一切,如果有人需要更多信息,请告诉我,我只需要更好地了解可能导致此错误的原因,以便找到修复它的途径。

这是带有 T-Hub 扩展的旧版代码库的问题。它是为PHP 5.3和Magento版本1.4及更低版本创建的。他们真的应该更新这个东西,因为人们正在使用它。

公司官方回应是:http://support4.atandra.com/index.php?/Knowledgebase/Article/View/92/4/magento-array_key_exists-error

这很可怕,因为它依赖于覆盖核心文件。

正在发生的事情是Mage_Captcha_Model_Observer有一个被触发的事件检查UserLoginBackend()。这期望"登录"的 POST 信息是某种格式。这是多年来已经改变的事情,因为遗留代码没有这种格式。

这是一个非常笨拙的修复。但这比覆盖核心 magento 文件要好。将 Mage/Thub/Model/Run/Run.php 的 CheckUser() 函数更改为此函数(我已经删除了他们的一些评论):

public function CheckUser()
{
    try {
        $username = $this->RequestParams['USERID'];
        $password = $this->RequestParams['PASSWORD'];
        //here we just set the POST to our specified format.. 
        //which is what the observer model thinks it should be
        Mage::app()->getRequest()->setPost('login', array(
            'username' => $username,
            'password' => $password
        ));
        $user = Mage::getSingleton('admin/user');
        $userRole = Mage::getSingleton('admin/role');
        if ($user->authenticate($username, $password)) {
            $loadRole = $userRole->load($user->getRoles($user));
        } else {
            print($this->xmlErrorResponse($this->RequestParams['COMMAND'], '9000',
                'Order download service authentication failure - Login/Password supplied did not match', $this->STORE_NAME, ''));
            exit;
        }
    } catch (Exception $e) {
        $this->Msg[] = "Critical Error CheckUser (Exception e)=" . $e->getMessage(); //BB 11Nov2014
        print($this->xmlErrorResponse($this->RequestParams['COMMAND'], '9001',
            'Service authentication failure - ' . " " . $e->getMessage(), $this->STORE_NAME, ''));
        // End - <TIBB> 13Dec2011
        exit;
    }
}

另一种选择是使用您自己的版本扩展Mage_Captcha_Model_Observer类,该版本删除了checkUserLoginBackend()中的数组检查。