jaheller
2097
9
Tips

code review / idea to solve problem

Posted 6 months ago by jaheller

I'm using some conversion rates inside my application. They are fetched every n minutes and stored inside a "config" table.

Each product has an accessor like this:

public function getPriceEUR()
{
    return intval($this->usd_price / SystemConfig::find(1)->value * 100);
}

I'm using this way to make sure I don't overload a webAPI. I figured out a problem, when displaying many products in a listing.

Every product listing will result in 1 database call to load SystemConfig::find(1)->value. This is for sure not a good way to go, using eager loading all the time and now this...any suggestions?

Please sign in or create an account to participate in this conversation.