Re #1692 prevent query repeats and not fetch rows which are not required

@jonpday please review
@parhamr  next line ->where("$columnName != ''"); should limit the result. 

If in any case it does not we need to investigate it further, as if config has hex value we need it in the category listing.