Save array entities

I have a problem:
I need to save many entities, but only one is saved. I don’t understand why. Tell me how to save everything.

my code in controller :

if ($this->request->is(‘ajax’)) {
$jsonData = $this->request->input(‘json_decode’);

     for($i=0; $i<=$jsonData.lenght; $i++){
            $order = $this->Clients_products->newEntity();

            $order->client_id = 2; 
            $order->product_id = $jsonData[$i]->id;

            if ($this->Clients_products->save($order)) {
                $this->Flash->success(__('OP!! OP!! OP!!.'));
            }else{
                $this->Flash->success(__('Hooop!.')); 
            }
        }

}

What is $jsonData.lenght?

1 Like

Thank you, Zuluru