【问题标题】:Empty product list for guest requests客户请求的空产品列表
【发布时间】: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 返回[])。将“所有”访客设置更改为手动选择的复选框也不能解决此问题。

【问题讨论】:

    标签: rest magento


    【解决方案1】:

    感谢blog post,我发现 Magento 不会在 REST API 中显示来宾角色的缺货产品。要更改此行为,请编辑设置 System &gt; Configuration &gt; Catalog &gt; Inventory &gt; Stock options &gt; Display out of stock products

    这种行为的原因可能是,客人不应该看到不可用的产品,因为他们无法订购或使用它们做任何事情。同时管理员可以看到它们,因为它们可能对他来说是可食用的(如果管理员角色已被授予该权限)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-28
      • 2010-10-30
      • 2021-03-07
      • 2019-10-21
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多