我的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;
}
登录并检索产品列表就可以了。
我的创作错误在哪里?谢谢
您需要检查此网络服务用户是否已在后端提供创建和删除权限。 如果没有,则授予创建产品的权限并检查它。