Access product information from PIMCORE using .net MVC project


#1

Hello,

I need to access the data from ‘PIMCORE’ through an API from .Net application in order to show the digital assets like images, documents., etc to customers.

So, you are always most welcome to share any sample projects on the same which would be helpful in implementing.


#2

Hi
For backward compatibility I had to implement it on vb.net
you should import Newtonsoft.Json

Public Function GetListOfObjects(objCon As PIM_Con) As Boolean
        Dim oPIM_ObjectList As PIM_ObjectList
        Dim getURL As String = ""

            getURL = objCon.url + "/object-list?apikey=" + objCon.apikey + "&" + sPT_Where
            Dim webClient As New System.Net.WebClient With {
                .Proxy = Nothing
            }
            Dim result As String = webClient.DownloadString(getURL).ToString

            oPIM_ObjectList = JsonConvert.DeserializeObject(Of PIM_ObjectList)(result)
            If oPIM_ObjectList.success Then
                'Run on each data object:
                For Each oPIMObject As PIM_Object In oPIM_ObjectList.data
                    If oPIMObject.published Then
                        GetObject(oPIMObject)
                    End If 'published
                Next 'list of object data
                Return True
            End If 'success
End Function

 Private Sub GetObject(oPIMObject As PIM_Object)
            getURL = objCon.url + "/object/id/" + CStr(oPIMObject.id) + "?apikey=" + objCon.apikey
          
            Dim objwebClient As New System.Net.WebClient With {
                                    .Proxy = Nothing
                                }
            Dim result As String = objwebClient.DownloadString(getURL).ToString
    Dim oPIM_ListofFields As PIM_ListofFields = JsonConvert.DeserializeObject(Of PIM_ListofFields)(result)

'oPIM_ListofFields is an object that contain all data 

    End Sub


Public Class PIM_Con
    Public url As String
    Public apikey As String
End Class
Public Class PIM_ObjectList
    Public success As Boolean
    Public total As Integer
    Public data As List(Of PIM_Object)
End Class
Public Class PIM_Object
    Public id As Integer
    Public type As String
    Public published As Boolean
    Public generation As Integer = 0
End Class
Public Class PIM_ListofFields
    Public success As Boolean
    Public data As PIM_FieldData
End Class
Public Class PIM_FieldData
    Public path As String
    Public elements As List(Of PIM_element)
    Public ClassName As String
    Public parentId As Integer
    Public key As String
    Public published As Boolean? = False
    Public type As String
    Public properties As String
End Class
Public Class PIM_element
    Public type As String
    Public value As Object
    Public name As String
    Public language As String
End Class

#3

Thanks for your post Mr. EliShklovsky.
In my case I have to consume it through C#, anyway this gives an idea of my implementation.

Any other posts regarding this are most welcome from anyone!