IMO this should be once, and not here. Yet I would do this by event & listener/subscriber to allow move of generation into some background systems for big shops (i.e. Gearman or AMQP etc.)