Magento API in C # .Net: directoryProductRequestAttributes problem

I have the code below trying to return a product with all the relevant attributes.

I do not get errors, but I do not see any attributes in the variable "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 } 
+4
source share
3 answers

Are you trying to get standard (built-in) attributes or custom?

Note that the catalogProductRequestAttributes object (which tells Magento which attributes you want to receive) has two collections: one for standard attributes and one for custom.

Something like this should work:

 // 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"); 
+4
source

try setting the last attribute in the ProductInfo directory to "nothing"

 objResource = magentoAPI.catalogProductInfo(gbl_strSession, productID, setStoreviewName, mc_filter, nothing) 

Magento 1.4 productIdentifierType

0
source

Dennis,

Based on a fairly large number of trial and error, the following worked for me:

1) The AttributeSet parameter in the catalogProductAttributeList () call must be an integer that Magento can identify as a known set of attributes. I worked with the default data that comes with Magento Go, and the numbers 9, 38, 39, 40, 41, 42, 44, 45, 46, 58, 59, 60, 61, and 62 worked. In this order, the total number of returns the attributes were 63, 67, 71, 68, 66, 68, 67, 65, 63, 63, 61, 63, 66 and 64. I see that a value of 9 should be sufficient for most products.

2) The second parameter in the catalogProductInfo () call must match the true Magento product_id. For example, if you are listing sales orders, the parameter might be the value of salesOrderItemEntity.product_id.

3) In addition to paragraph 2 above, the last parameter in the catalogProductInfo () call must be zero.

If you use SKU instead of product_id, then the second parameter should be the SKU of the product (not the product identifier), and the last parameter should be "sku".

Hope this helps.

PS: All attribute sets (corresponding to the 14 identifiers above, for example) can be listed with catalogProductAttributeSetList (), which returns an array of objcatalogProductAttributeSetEntity objects.

0
source

All Articles