【发布时间】:2014-11-28 01:23:24
【问题描述】:
我正在尝试使用访客帐户通过 REST API 读取 Magento 产品列表。我的 Magento 实例按预期响应 GET /api/rest/products/1,其中:
<?xml version="1.0"?>
<magento_api>
<entity_id>1</entity_id>
<type_id>simple</type_id>
<sku>simple_sku</sku>
<name>simple</name>
<meta_title/>
<meta_description/>
<description>description</description>
<short_description>short description</short_description>
<meta_keyword/>
<tier_price/>
<is_in_stock>0</is_in_stock>
<regular_price_with_tax>100</regular_price_with_tax>
<regular_price_without_tax>100</regular_price_without_tax>
<final_price_with_tax>100</final_price_with_tax>
<final_price_without_tax>100</final_price_without_tax>
<is_saleable>0</is_saleable>
<image_url>http://localhost/media/catalog/product/cache/0/image/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/image.jpg</image_url>
<url>http://localhost/index.php/catalog/product/view/id/1/s/simple/</url>
<buy_now_url>http://localhost/index.php/checkout/cart/add/uenc/aHR0cDovL2xvY2FsaG9zdC9hcGkvcmVzdC9wcm9kdWN0cy8x/product/1/form_key/6DQ0mBsIua4HpuGN/</buy_now_url>
<total_reviews_count>0</total_reviews_count>
<has_custom_options/>
</magento_api>
但是,使用 GET /api/rest/products 向同一个 Magento 实例询问产品列表会返回空结果,而我希望列表包含该产品:
<?xml version="1.0"?>
<magento_api/>
以 oauth 身份验证用户身份调用时,结果已正确填充,但我需要它为访客帐户工作。
Guest REST 角色已配置为获取“全部”资源访问权限和“全部”属性。对于 Magento 版本 1.9.0.1 和 1.9.1.0,我对两种格式都有这种行为:xml 和 json,(json 返回[])。将“所有”访客设置更改为手动选择的复选框也不能解决此问题。
【问题讨论】: