How to count the occurrence of items in a list?

My task is to count the frequency of each product ID in a given list. However, the current code is inefficient as it only counts one ID at a time.

Can someone provide with me a code that helps me to count the occurrences of every element in a list?