magento创建产品的错误

时间:2015-03-16 09:44:51

标签: php magento soap

我的magento api错误比我创建产品错误:

Fatal error: Uncaught SoapFault exception: [2] Access denied. in /Applications/MAMP/htdocs/magento/soap.php:210 Stack trace: #0 /Applications/MAMP/htdocs/magento/soap.php(210): SoapClient->__call('call', Array) #1 /Applications/MAMP/htdocs/magento/soap.php(210): SoapClient->call('2017c612ade741b...', 'product_attribu...') #2 /Applications/MAMP/htdocs/magento/soap.php(90): Client->_APIgetAttributeSets() #3 /Applications/MAMP/htdocs/magento/soap.php(269): Client->APIcreateNewProduct(Array) #4 {main} thrown in /Applications/MAMP/htdocs/magento/soap.php on line 210

这是我的方法:

public function APIcreateNewProduct( $newProductData ) {

    $error = array();

    if( empty( $newProductData ) ) {
        $error[] = 'Empty product data';
    }

    if( empty( $error ) ) {

        $token = $this->_getToken();
        $client = $this->_getClient();
//90 line
        $set = $this->_APIgetAttributeSets();

        $productId = $client->call($token, self::CREATE_PRODUCT, array('simple', $set['set_id'], rand().'sku_of_product', $newProductData));
        return $productId;

    } else {
        return $this->_apiJsonResult( $error );
    }

}

及其_APIgetAttributeSets():

private function _APIgetAttributeSets() {

    $token = $this->_getToken();
    $client = $this->_getClient();
//210 LINE
    $attributeSets = $client->call($token, self::PRODUCT_ATTRIBUTE_LIST);
    $set = current($attributeSets);

    return $set;
}

登录并检索产品列表很好。

创建时我的错误在哪里?谢谢

1 个答案:

答案 0 :(得分:0)

您需要检查此Web服务用户是否在后端提供了create和delete权限。如果没有,那么给予创建产品的权利并检查它。