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);
}
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

  • 1
    I am already doing this. – Sonu Kapoor Feb 13 '15 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.