Page 1 of 1

Programmatically getting all products from all categories

Posted: Tue Apr 05, 2016 5:23 pm
by yattias
Hi,

Recently upgraded to Gold and am unable to load all products from all categories. In the past, I used to be able to do this:

Code: Select all

    Function GetProducts() As ArrayList
        Dim dataSource As ProductDataSource = New ProductDataSource()
        Dim productCollection As ProductCollection = dataSource.LoadForStore()    
        Dim pArray As ArrayList = New ArrayList()
      
        For Each product As Product In productCollection
            pArray.Add(product.Name)
        Next

        Return pArray
    End Function
But now, this no longer works. What do I need to do to fix the above code?

Thank you.

Re: Programmatically getting all products from all categories

Posted: Wed Apr 06, 2016 2:22 am
by nadeem
Try something like this

Code: Select all

Function GetProducts() As ArrayList
        Dim dataSource As ProductDataSource = New ProductDataSource()
        Dim productCollection As IList(Of Product) = dataSource.LoadForStore(AbleContext.Current.Store.Id)   
        Dim pArray As ArrayList = New ArrayList()
     
        For Each product As Product In productCollection
            pArray.Add(product.Name)
        Next

        Return pArray
    End Function