如何获取 Magento 产品的所有附加属性而不显式指定它们
我的目标是使用 SOAP API 获取并显示 Magento 产品的所有附加属性。例如 T 恤产品的性别、衬衫尺码和颜色。但程序不应该知道属性名称。
在 SOAP 调用:catalogProductInfo 中,有附加属性参数,看起来我必须显式指定附加属性名称。
我正在使用 Java 和 Apache Axis 连接到 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 来完成?
更新:“*”作为属性不起作用
CatalogProductRequestAttributes attrs = new CatalogProductRequestAttributes();
attrs.setAttributes(new String[] {"*"});
attrs.setAdditional_attributes(new String[] {"*"});
结果对象既不填充标准属性,也不填充附加属性。
My goal is to get and display all additional attributes for the Magento product using SOAP API. For example Gender, Shirt Size and Color for T-Shirt product. But the program shouldn't know the attribute names.
In the SOAP Call: catalogProductInfo there is additional attributes parameter and it looks like I have to explicitly specify additional attribute names.
I am using Java and Apache Axis to connect to Mangeto SOAP API and the code is following:
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) {
But I have to specify last parameter somehow to get all additional attributes.
Is it possible to do through SOAP API?
Update: "*" as attribute doesn't work
CatalogProductRequestAttributes attrs = new CatalogProductRequestAttributes();
attrs.setAttributes(new String[] {"*"});
attrs.setAdditional_attributes(new String[] {"*"});
Resulted object is not filled neither with standard attributes nor with additional attributes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有专门尝试过 API,但是您是否尝试过指定
*
作为属性名称?这就是框架本身的完成方式。I haven't tried through the API specifically, but have you tried specifying
*
as the attribute name? That's how it's done in the framework itself.您首先必须调用 API 来获取附加属性列表:
CatalogProductListOfAdditionalAttributes
然后循环结果并构建对特定产品的第二个请求。
You first have to call the API for the list of additional attributes:
catalogProductListOfAdditionalAttributes
Then loop through the results and construct your second request to specific product.