7

I am currently using a foreach loop to iterate through the products and then retrieving the attribute I need. This is very slow, because it makes a call for each product to the API and retrieves the attributes values.

Is there a way to get all products along with their attributes in one shot?

Here is my current code:

var session = client.login("xxx", "xxx");
catalogProductEntity[] product = new[] { new catalogProductEntity() };
client.catalogProductList(out product, session, null, null);
Console.WriteLine("Found {0} items", product.Length);

catalogProductRequestAttributes attributes = new catalogProductRequestAttributes();
attributes.additional_attributes = new string[] { "mynewattribute" };

foreach (var catalogProductEntity in product)
{
    catalogProductReturnEntity catalogProductReturnEntity = client.catalogProductInfo(session, catalogProductEntity.product_id, null, attributes, null);
    string attrValue = catalogProductReturnEntity.additional_attributes[0].value;
    Console.WriteLine("attrValue => " + attrValue);
    Console.WriteLine(catalogProductEntity.product_id);
}
Matthias Zeis
  • 7,697
  • 3
  • 32
  • 50
Sonu Kapoor
  • 171
  • 1
  • 4

1 Answers1

1

Magento doenn't have the single api those return the list of products and its all attributes(system + custom). you need to call two separted API:

  1. For getting list of products and its system attributes

    - catalog_product.list (SOAP V1)
    - catalogProductList (SOAP V2)
    
  2. For getting user defined attributes from products

    - product.listOfAdditionalAttributes (SOAP V1)
    - catalogProductListOfAdditionalAttributes (SOAP V2)
    

    Please refer below links for more details. http://www.magentocommerce.com/api/soap/catalog

Abhishek Gupta
  • 1,185
  • 8
  • 17