繁体   English   中英

在尝试添加优惠券时,Magento API会拒绝访问

[英]Magento API gives Access Denied when trying to add a coupon

我正在使用SOAP API for Magento(v1.5.1.0),并设法获得创建购物车,添加用户,添加帐单/送货地址,付款方式等工作的整个过程,但我无法获得优惠券工作。

我正在使用的代码如下:

    if ($couponCode != '') {
        try {
            $result = $this->magentoservice->shoppingCartCouponAdd($sessionId, $cartId, $couponCode);                
        } catch (Exception $err) {
            return $this->returnError($err->getMessage());
        }
    }

我已经尝试过访客用户和注册用户,并且我一直得到同样的异常 - “访问被拒绝。”。 据我所知,从有限的文档和论坛帖子来看,这甚至都不是预期的错误。

$ sessionId和$ cartId肯定有效。 $ couponCode如果直接输入magento前端工作。

任何人都可以告诉我如何解决这个问题?

感谢John,我在magento.stackexchange.com网站上得到了答案。

https://magento.stackexchange.com/questions/2729/magento-api-gives-access-denied-when-trying-to-add-a-coupon

问题是api角色不包括优惠券的访问权限。 然而,我没有看到这个的原因是由于它没有显示在后端。

直接编辑api_role表我能够将购物车优惠券的4条记录设置为允许。

基于@ Hyarion的回答,Magento v1.7中接收Access Denied权限的问题是,优惠券权限没有出现在Admin > System > Web Services > xxx Roles > (select Role) > Role Resources所以我可以不为我的API用户启用它们。

对我有用的修复是运行此数据库查询,这将影响3个记录(每个角色):

update api_rule set api_permission='allow' where role_id=1 -- Replace with your desired role id and resource_id like 'cart/coupon%'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM