0

Hi I have a simple code below that fetches, make, model and year from the database, but for some weird reason I get:
Fatal error: Cannot access protected property error, any ideas as to why this might be happening? (i btw have this code on a different server running with no issues.)

$count = 0;

foreach( $_product->getFitModels() as $fit ) {

    $trimmedData = ' '.$fit->row->make.' '.$fit->row->model.' '.$fit->row->year;

    $tempMMYArray[] = $trimmedData;     

}

Edited by andy106

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by johrocks124
2

Because you can only access protected properties and methods from the same class or a child class. If you want to access them from outside the class you need to make them public.

Votes + Comments
thank you!
1

I must be really tired.. lol.. of course, the property was protected, here is the fix:

class my_vehcile_row implements this_is_Configurable
{
    public $row;
 //etc 
 }
0

because you can acesss it through the same class or child class .
this is the reason you are getting this error

SNIP

Edited by happygeek: spam deleted

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.