1

Magento SOAP API v2 を呼び出して、vb.net の一連の日付の間のすべての販売注文を取得するにはどうすればよいですか?

これは私がこれまでに試したこと0ですが、販売注文が存在するにもかかわらず返されます。

Dim ae As associativeEntity = New associativeEntity()
ae.key = "status"
ae.value = "processing"
Dim params As filters = New filters

Dim dateFilter As complexFilter
dateFilter = New complexFilter()
dateFilter.key = "created_at"
Dim nestedFilterFrom As associativeMultiEntity = New associativeMultiEntity()
nestedFilterFrom.key = "gteq"
nestedFilterFrom.value = New String() {DateTime.Parse(fromDate).ToUniversalTime.ToString()}
dateFilter.value = nestedFilterFrom
Dim dateToFilter As complexFilter = New complexFilter()
Dim nestedFilterTo As associativeMultiEntity = New associativeMultiEntity()
nestedFilterTo.key = "lteq"
nestedFilterTo.value = New String() {DateTime.Parse(toDate).ToUniversalTime.ToString()}
dateToFilter.key = "created_at"
dateToFilter.value = nestedFilterTo

params.complex_filter = New complexFilter() {dateFilter, dateToFilter}    
magentoWS.salesOrderList(sessionID, params)

以下のように、同じコードを使用してステータスの照合を行うことができました。

Dim ae As associativeEntity = New associativeEntity
Dim params As filters = New filters()
ae.key = "status"
ae.value = "processing"
params.filter = New associativeEntity() {ae}
magentoWS.salesOrderList(sessionID, params)
4

2 に答える 2

1

フィルターを機能させるには、日付形式を次のようにする必要があります。

YYYY-MM-DD

これは、Magento のSOAP "v2" XML Request exampleにあった方法であるため、これを発見しただけです。ドキュメントまたは彼らの応答でこれを指定するのは良かったのですが、se la vie . 誰かが興味を持っている場合は、ここにコードがあります。

Dim ae As associativeEntity = New associativeEntity With { .key = "status", .value = "processing" }
Dim params As filters = New filters

Const createdAt As String = "created_at"
Const magentoDateTimeFormat As String = "yyyy-MM-dd"

Dim nestedFilterFrom As associativeMultiEntity =
    New associativeMultiEntity With {.key = "from", .value = New String() {fromDate.ToString(magentoDateTimeFormat)}}
Dim dateFromFilter As complexFilter = New complexFilter With {.key = createdAt, .value = nestedFilterFrom}

Dim nestedFilterTo As associativeMultiEntity =
    New associativeMultiEntity With {.key = "to", .value = New String() {toDate.ToString(magentoDateTimeFormat)}}
Dim dateToFilter As complexFilter = New complexFilter With {.key = createdAt, .value = nestedFilterFrom}

params.complex_filter = New complexFilter() {dateFromFilter, dateToFilter}    
magentoWS.salesOrderList(sessionID, params)

fromこの場合、およびフィルターはおよび とto同等であることに注意してください。この文脈では と がより理にかなっていることがわかりましたが、結果は同じです。lteqgteqfromto

于 2013-08-08T15:02:06.613 に答える
0
Public Function getMageOrdersListByFilter(ByVal fromDate As DateTime, ByVal toDate As DateTime) As MagentoService.salesOrderListEntity()
    GetMageSessionId()

    Dim f As MagentoService.filters = New MagentoService.filters

    Const createdAt As String = "created_at"
    Dim magentoDateTimeFormat As String = "yyyy-MM-dd"
    magentoDateTimeFormat = "yyyy-MM-dd HH:mm:ss"

    Dim cpf(2) As MagentoService.complexFilter
    cpf(0) = New MagentoService.complexFilter With {.key = createdAt, .value = New MagentoService.associativeEntity With {.key = "from", .value = New String(fromDate.ToString(magentoDateTimeFormat))}}
    'HACK FIX: http://www.magentocommerce.com/bug-tracking/issue?issue=8073
    cpf(1) = New MagentoService.complexFilter With {.key = "/*fake*/created_at", .value = New MagentoService.associativeEntity With {.key = "to", .value = New String(toDate.ToString(magentoDateTimeFormat))}}

    f.complex_filter = cpf

    Dim oList() As MagentoService.salesOrderListEntity = Nothing

    Try
        oList = mage.salesOrderList(sessionId, f)
    Catch ex As Exception

    End Try

    Return oList

End Function
于 2013-10-18T15:12:17.593 に答える