Fix PHP Product Class and Stats PHP errors

Errors were result of instantiating a product using a product id corresponding to a product that was deleted.  As this is a normal occurrence as products come and go from a store the instantiation isn't the problem, but doing some operations on it is a problem.

Before doing these operations a check is made to see if they are permitted.