Have you used some debug statements to check if you're getting what
you think you're getting from that loop?
Chris
On Aug 7, 4:48 am, Mike Digital Egg <[EMAIL PROTECTED]> wrote:
> Hi Samuel,
>
> Thanks for your reply, I'm sure this is the right solution, I just
> can't seem to get it to work:
>
> function afterFind( $results ) {
> foreach ($results as $key => $val) {
> if ( isset($val["Product"]["list_price"]) ) {
> $results[$key]["Product"]["list_price"] =
> $val["Product"]
> ["list_price"] - 1.99;
> }
> }
> return $results;
> }
>
> It is just not applying the discount, is the code correct? Am I
> missing something?
>
> Thanks
>
> Mike
>
> On Aug 6, 6:06 pm, "Samuel DeVore" <[EMAIL PROTECTED]> wrote:
>
> > function afterFind($results) {
> > foreach ($results as $key => $val) {
> > // do your thing
> > }
> > }
> > return $results;
> > }
>
> > On 8/6/07, Mike Digital Egg <[EMAIL PROTECTED]> wrote:
>
> > > Hi Tulio,
>
> > > Thanks for the tip, I think that might have been what I was thinking
> > > of :)
>
> > > I have tried it in the model though and it doesn't seem to work:
>
> > > function afterFind( $results ) {
> > > $results->list_price = $results->list_price - 1.99;
> > > return $results;
> > > }
>
> > > Am I using the correct code here?
>
> > > I would expect all the prices throughout the site to be - 1.99 but
> > > they are still the same.
>
> > > Any ideas?
>
> > > Cheers
>
> > > Mike
>
> > > On Aug 6, 5:57 pm, Tulio Faria <[EMAIL PROTECTED]> wrote:
> > > > Hi,
>
> > > > you could use: afterFind($results) where $results is the result of the
> > > > find, like findAll...
>
> > > > []'s
>
> > > > On Aug 6, 12:52 pm, Mike Digital Egg <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi,
>
> > > > > I would like to adjust a price coming out of the database at the model
> > > > > level so that it is consistent throughout the site.
>
> > > > > I thought I had done something like this before:
>
> > > > > class Product extends AppModel {
>
> > > > > var $name = 'Product';
>
> > > > > function beforeFilter() {
> > > > > $this->list_price = $this->list_price - $discount;
> > > > > return $this;
> > > > > }
>
> > > > > }
>
> > > > > but I can't find any documentation about the beforeFilter function in
> > > > > a model, maybe I did it before in Ruby on Rails? Can this be done in
> > > > > Cake?
>
> > > > > Thanks
>
> > > > > Mike
>
> > --
> > (the old fart) the advice is free, the lack of crankiness will cost you
>
> > - its a fine line between a real question and an idiot
>
> >http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---