我有下面的代码,试图让产品返回所有相关属性。
我没有收到任何错误,但我在“prod”变量中没有看到任何属性。
private void frmProductDetail_Load(object sender, EventArgs e)
{
MagentoService service = new MagentoService();
MagentoServiceHelper help = MagentoServiceHelper.Instance;
catalogAttributeEntity[] attributes = service.catalogProductAttributeList(help.SessionID, AttributeSet); //AttributeSet is a property of the form
catalogProductRequestAttributes att = new catalogProductRequestAttributes();
string[] attlist = new string[attributes.Length];
for (int i = 0; i < attributes.Length; i++)
{
attlist[i] = attributes[i].code;
}
att.attributes = attlist;
catalogProductReturnEntity prod = service.catalogProductInfo(help.SessionID,
ProductId, "default", att, "sku"); //ProductId is a property of the form
}
Run Code Online (Sandbox Code Playgroud)
您是要获取标准(内置)属性还是自定义属性?
请注意,catalogProductRequestAttributes对象(它告诉 Magento 您想要获取哪些属性)有两个集合 - 一个用于标准属性,另一个用于自定义。
这样的事情应该工作:
// assumes sessionId, sku and storeView are defined already
catalogProductRequestAttributes fetchattrib = new catalogProductRequestAttributes();
// it will only populate the attributes that you ask for
fetchattrib.attributes = new string[] { "name", "description", "short_description"};
fetchattrib.additional_attributes = new string[] { "number_of_legs", "can_jump"};
catalogProductReturnEntity prod = m_magentoClient.catalogProductInfo(
sessionId, sku, storeView, fetchattrib, "sku");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4670 次 |
| 最近记录: |