aimeos / aimeos-core

Aimeos PHP e-commerce framework for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org
Other
3.26k stars 112 forks source link

[Suggestion]manager find method return #314

Closed Sirick93 closed 6 months ago

Sirick93 commented 6 months ago

Why would a find method throw an exception if a record wasn't found and not return null? I think this should be changed. We are forced to make a try catch block instead of a simple if statement.

aimeos commented 6 months ago

find() requires to return an item so you are sure, you get one at all circumstances. It should be also used for single items only, not in a loop because this is slow and ineffective. In that case, use search() instead to retrieve all items you are looking for at once and loop over them afterwards.