I'm trying to save an Array $sales.
Here the data into this Array:
sales
0
Product
id146
category
descriptiondrei
created2013-11-20 14:10:12
modified2013-11-20 14:10:12
shop_id27
category_id1
image(null)
Shop
id27
user_id23
titlebarby
descriptionkleines
created2013-10-29 12:51:32
modified2013-10-29 12:51:32
Category
id1
imageHaushalt
The method in the Controller look like this:
public function save_notepad() {
$sales = array();
if($this -> Session -> valid() && $this -> Session -> check('notepad')) {
$notepad = $this -> Session -> read('notepad');
$this->loadModel('Product');
$condition = array('Product.id' => $notepad);
$sales = $this -> Product-> find('all', array('conditions' => $condition));
}
$this -> set('sales', $sales);
if ($this->request->is('post')) {
$this->Sale->create();
if ($this->Sale->saveall($sales));
$this->Session->setFlash(__('The sale has been saved'));
return $this->redirect(array('action' => 'index'));
}
}
The Problem is, that when I save, in the database it saves just the id and the created date.
The Model Looks like this: class Sale extends AppModel {
public $belongsTo = array(
'Product' => array(
'className' => 'Product',
'foreignKey' => 'product_id',
'conditions' => array('Product.id' => 'Sale.product_id'),
'fields' => '',
'order' => ''
),
'Shop' => array(
'className' => 'Shop',
'foreignKey' => 'shop_id',
'conditions' => '',
'fields' => '',
'order' => ''
));
}
What do I need to do for saving also the "product_id" and the "shop_id" which are already in the Array $sales?
Thanks for helping!