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

时间:2016-01-29 22:08:37

标签: rest magento

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

我收到了一个内部错误:

  

“message”:“类Magento \ TargetRule \ Model \ Catalog \ Product \ Attribute \ Backend \ Rule不存在”,   “trace”:“#0 /var/www/html/magento2/vendor/magento/module-catalog-inventory/Model/StockRegistry.php(194):Magento \ CatalogInventory \ Model \ Stock \ StockItemRepository-> save(Object (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(对象(Magento \ Framework \ App \ Request \ Http))\ n#5 / var / www / html / magento2 / vendor /magento/framework/App/Http.php(115):Magento \ Webapi \ Controller \ Rest \ Interceptor-> dispatch(Object(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 {main}“

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

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:-1)

请在此处发布您的代码,以便任何人检查代码,并可以建议您做错了什么。

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

error_reporting(E_ALL); 

ini_set(“display_errors”,1);

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