catalog SQL optimisations.

Authored by @toporchillo.

It just mixed with whitespace-changes in only 4 needed files. It was really too hard to redo patch to fully ignore whitespace differences between my fork and original OpenCart (and fully minimize diff between commits).

Anyway, as @rb2 mentioned in #545, clean diff can be viewed by ```git diff -b eec34c7548e035f64c98f453d5888712654a5517~1..eec34c7548e035f64c98f453d5888712654a5517```