If I used a function model afterFindto set up data based on their GEO location, for example:
function afterFind($results)
{
if( $userInArea)
{
if(!isset($results[0]['Product']['price']))
{
return $results;
}
foreach ($results as $key => $val)
{
$results[$key]['Product']['price'] = $this->priceAdjustAfterFind($val['Product']['price']);
}
return $results;
}
}
function priceAdjustAfterFind($price)
{
return $price * 1.2;
}
This would make the price field of the data returned by the model 20% higher if in a specific area.
The problem is this:
Suppose the price is 100. The administrator is in the GEO zone and proceeds to edit the product admin/product/edit/4. The data given in edit viewfrom product modelwill be increased to 120, since it is located in the GEO zone and will cause a price adjustment.
So, as soon as she saves (let's say she adjusted the name), she will inadvertently change the price from 100 to 120. Now, if she edits her again, she will load as 144, increasing each time.
. ?