代码之家  ›  专栏  ›  技术社区  ›  Vladimir

如何获取magento产品的所有附加属性而不显式指定它们

  •  4
  • Vladimir  · 技术社区  · 15 年前

    我的目标是使用SOAP API获取和显示magento产品的所有附加属性。例如,T恤产品的性别、衬衫尺寸和颜色。但是程序不应该知道属性名。

    在soap调用catalogProductInfo中,有附加的attributes参数,看起来我必须显式地指定附加的属性名。

    我使用Java和Apache轴连接到Mangeto SOAP API,代码如下:

    stub.catalogProductInfo(sessionId, "118", null, null);
    
    call declaration:
    public com.magentocommerce.api.CatalogProductReturnEntity catalogProductInfo(java.lang.String sessionId, java.lang.String productId, java.lang.String storeView, com.magentocommerce.api.CatalogProductRequestAttributes attributes) throws java.rmi.RemoteException {
    
    attributes parameter constructor declaration:
    public CatalogProductRequestAttributes(
           java.lang.String[] attributes,
           java.lang.String[] additional_attributes) {
    

    但我必须以某种方式指定最后一个参数来获取所有附加属性。 是否可以通过SOAP API完成?

    更新 :“*”as属性不起作用

    CatalogProductRequestAttributes attrs = new CatalogProductRequestAttributes();
    attrs.setAttributes(new String[] {"*"});
    attrs.setAdditional_attributes(new String[] {"*"});
    

    结果对象既不填充标准属性,也不填充其他属性。

    2 回复  |  直到 11 年前
        1
  •  1
  •   Joe Mastey    15 年前

    我没有具体尝试过API,但您是否尝试过指定 * 作为属性名?这就是框架本身的工作方式。

        2
  •  0
  •   danbars    11 年前

    您首先必须调用API以获取附加属性列表: 目录产品目录附加属性

    然后循环遍历结果并构造对特定产品的第二个请求。

    推荐文章