How would i save the following;
I want the first 4 items to apply to all the “products to be saved”, given that this data is at the top of my form and “global” to the products that get saved how would i tell cakephp to save it to each product or do i have to create a foreach loop and manually insert the data?
Global data to each product.
[discount_id] => 17 [range_id] => 21 [category_id] => 6 [user_id] => 104
Array
(
[Product] => Array
(
[discount_id] => 17
[range_id] => 21
[category_id] => 6
[user_id] => 104
[0] => Array
(
[product_code] => ffff
[colour] => red
[lead_time_weeks] =>
[description] =>
[height] => 11111
[width] => 22222
[depth] =>
[price] =>
[discount] => 50
[discounted_price] =>
[quantity] =>
)
[1] => Array
(
[product_code] => fgfgfggf
[colour] => red
[lead_time_weeks] =>
[description] =>
[height] => 123
[width] => 123
[depth] =>
[price] =>
[discount] => 50
[discounted_price] =>
[quantity] =>
)
)
)
Save method in controller
$this->Product->saveAll($this->request->data['Product']
I would personally use a foreach loop, saveAll is meant for saving associated data.
e.g.