Hello, I’m trying to use the Dolibarr API module to get a list of products sorted by update date (I’m trying to get a list of the 100 products that were last updated/modified). I have a fresh install of dolibarr v15 with the api module activated.
When using the API, through the /products
endpoint with the sortfield
query, if I leave the default t.ref
argument it works fine and returns my products and services as such:
{
"label": "Mock service",
"description": "A mock service",
"other": null,
"type": "1",
"price": "100.00000000",
"price_ttc": "120.00000000",
"price_min": "100.00000000",
"price_min_ttc": "120.00000000",
"price_base_type": "HT",
"multiprices": [],
"multiprices_ttc": [],
"multiprices_base_type": [],
"multiprices_min": [],
"multiprices_min_ttc": [],
"multiprices_tva_tx": [],
"prices_by_qty": [],
"prices_by_qty_list": [],
"multilangs": [],
"default_vat_code": null,
"tva_tx": "20.0000",
"localtax1_tx": "0.0000",
"localtax2_tx": "0.0000",
"localtax1_type": "0",
"localtax2_type": "0",
"lifetime": null,
"qc_frequency": null,
"cost_price": null,
"pmp": "0.00000000",
"seuil_stock_alerte": "0",
"desiredstock": "0",
"duration_value": "1",
"duration_unit": "d",
"status": "1",
"status_buy": "1",
"finished": null,
"fk_default_bom": null,
"status_batch": "0",
"batch_mask": "",
"customcode": "",
"url": null,
"weight": null,
"weight_units": null,
"length": null,
"length_units": null,
"width": null,
"width_units": null,
"height": null,
"height_units": null,
"surface": null,
"surface_units": null,
"volume": null,
"volume_units": null,
"net_measure": null,
"net_measure_units": null,
"accountancy_code_sell": "",
"accountancy_code_sell_intra": "",
"accountancy_code_sell_export": "",
"accountancy_code_buy": "",
"accountancy_code_buy_intra": "",
"accountancy_code_buy_export": "",
"barcode": null,
"barcode_type": null,
"date_creation": "2022-04-04 12:29:53",
"date_modification": "2022-04-04 12:29:53",
"fk_default_warehouse": null,
"fk_price_expression": null,
"fk_unit": null,
"price_autogen": "0",
"is_object_used": null,
"mandatory_period": "0",
"id": "2",
"entity": "1",
"validateFieldsErrors": [],
"import_key": null,
"array_options": [],
"array_languages": null,
"linkedObjectsIds": null,
"canvas": "",
"ref": "MOCK2265",
"ref_ext": null,
"country_id": null,
"country_code": "",
"state_id": null,
"region_id": null,
"barcode_type_coder": null,
"last_main_doc": null,
"note_public": null,
"note_private": "",
"total_ht": null,
"total_tva": null,
"total_localtax1": null,
"total_localtax2": null,
"total_ttc": null,
"date_validation": null,
"specimen": 0,
"duration": "1d"
}
Now this is nice, but I notice the date_modification
attribute in the product returned, I’d like to sort by modification date so I try and get the products with t.date_modification
as value for the sortfield query, however now it doesn’t want to work, returning:
Service Unavailable: Error when retrieve product list : Unknown column 't.date_modification' in 'order clause'
But the date_modification attribute appears quite literally in the original response. Is there any possible way for me to get a list of product sorted by modification date ?