簡體   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