首页 文章

如何调试Magento 2 REST API错误 - catalogInventoryStockRegistry

提问于
浏览
0

我正在尝试将Magento与我们自己的库存管理集成在一起 . 使用catalogInventoryStockRegistry POST API时:http://magento-dev/rest/V1/products/T760/stockItems/2

我收到了一个内部错误:

“消息”:“类Magento \ TargetRule \ Model \ Catalog \ Product \ Attribute \ Backend \ Rule不存在”,“跟踪”:“#0 / var / www / html / magento2 / vendor / magento / module-catalog -inventory / Model / StockRegistry.php(194):Magento \ CatalogInventory \ Model \ Stock \ StockItemRepository-> save(对象(Magento \ CatalogInventory \ Model \ Stock \ Item))\ n#1 [内部函数]:Magento \ CatalogInventory \ Model \ StockRegistry-> updateStockItemBySku('T760',Object(Magento \ CatalogInventory \ Model \ Stock \ Item))\ n#2 / var / www / html / magento2 / vendor / magento / module-webapi / Controller / Rest . php(265):call_user_func_array(Array,Array)\ n#3 /var/www/html/magento2/vendor/magento/module-webapi/Controller/Rest.php(160):Magento \ Webapi \ Controller \ Rest-> processApiRequest()\ n#4 /var/www/html/magento2/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24):Magento \ Webapi \ Controller \ Rest-> dispatch(Object(Magento \) Framework \ App \ Request \ Http))\ n#5 /var/www/html/magento2/vendor/magento/framework/App/Http.php(115):Magento \ Webapi \ Controller \ Res t \ Interceptor-> dispatch(对象(Magento \ Framework \ App \ Request \ Http))\ n#6 /var/www/html/magento2/vendor/magento/framework/App/Bootstrap.php(258):Magento \ Framework \ App \ Http-> launch()\ n#7 /var/www/html/magento2/pub/index.php(37):Magento \ Framework \ App \ Bootstrap-> run(对象(Magento \ Framework \ App) \ Http))\ n#8

我的所有ID都应该有效 - 我使用了GET的输出数据,只需更新数量 . 有关如何找出哪个规则失败的任何建议?

2 回答

  • -1

    您的API可能不是问题 . 关于您看到的错误,我的问题是M2样本数据添加了引用“TargetRule”类的EAV属性,但不包括该模块 .

    您可以从数据库中删除这些属性,或者只安装没有样本数据的新M2实例 .

  • 0

    请在这里发布您的代码,以便任何人检查代码,并可以给你建议你做错了什么 .

    如果你正在使用magento rest API,那么在文件的开头写下面的代码

    error_reporting(E_ALL);
    

    ini_set(“display_errors”,1);

    require_once'../ app / Math.php';法师::应用程式();

相关问题