Magento Rest API 2.4: search with condition on order status

Viewed 651

we have REST API to Magento that worked with version 2.2. Now, after a migration to V2.4 a search request with a condition on "status" delivers an internal server error.

The Mageto Log File report says "... Column 'status' in where clause is ambiguous.. "

Here the query that does not work anymore:

$request = new Request('GET', 'index.php/rest/V1/orders/?'
                  .'fields=items[entity_id,increment_id]'
                  .'&searchCriteria[page_size]=' . $pageSize
                  .'&searchCriteria[current_page]=' . $currentPage

                  .'&searchCriteria[filter_groups][0][filters][0][field]=updated_at'
                  .'&searchCriteria[filter_groups][0][filters][0][value]=' . $lastProcessedUpdateTimestamp
                  .'&searchCriteria[filter_groups][0][filters][0][condition_type]=gt'

                  .'&searchCriteria[filter_groups][1][filters][0][field]=status'
                  .'&searchCriteria[filter_groups][1][filters][0][value]=pending'
                  .'&searchCriteria[filter_groups][1][filters][0][condition_type]=eq'

                  .'&searchCriteria[filter_groups][2][filters][0][field]=store_id'
                  .'&searchCriteria[filter_groups][2][filters][0][value]=2'
                  .'&searchCriteria[filter_groups][2][filters][0][condition_type]=eq',
                $this->httpHeaders);

The following query works:

$request = new Request('GET', 'index.php/rest/V1/orders/?'
                  .'fields=items[entity_id,increment_id]'
                  .'&searchCriteria[page_size]=' . $pageSize
                  .'&searchCriteria[current_page]=' . $currentPage

                  .'&searchCriteria[filter_groups][0][filters][0][field]=updated_at'
                  .'&searchCriteria[filter_groups][0][filters][0][value]=' . $lastProcessedUpdateTimestamp
                  .'&searchCriteria[filter_groups][0][filters][0][condition_type]=gt'

                  .'&searchCriteria[filter_groups][2][filters][0][field]=store_id'
                  .'&searchCriteria[filter_groups][2][filters][0][value]=2'
                  .'&searchCriteria[filter_groups][2][filters][0][condition_type]=eq',
                $this->httpHeaders);

Any idea?

Best regards,

Werner

1 Answers

Meanwhile it turned out that it is very likely that the problem is caused by an extension of the Magento Store: The AddressFactory of Deutsche Post AG (https://marketplace.magento.com/deutschepost-module-addressfactory-m2.html).

It seems that the extension causes that the SQL statement generated from a REST API call (search for orders with a certain "status") includes a join to a AddressFactors table that also includes a "status" column.

However, it is possibe to include the "status" attribute as output of the Rest API call and to do the filter step in the calling program.

Related