我尝试从API数组中插入一些数据,以将它们插入sales_flat_order_grid和sales_flat_order以及sales_flat_order_address。 对于最后一个,我可以毫无问题地插入数据,但是在 sales_flat_order_grid 中,但是没有办法手动或插入数组。
Foreach($array as $value){
$array = array(
'status' => $value['status'],
'base_grand_total' => $value['price'],
'grand_total' => $value['price'],
'increment_id' => $value['number'],
'base_currency_code' => 'MXN',
'shipping_name' => $value['name'],
'global_currency_code' => 'MXN',
'order_currency_code' => 'MXN',
'store_name' => 'linio marketplace',
'created_at' => $value['created'],
'updated_at' => $value['created']);
$modele = Mage::getModel('thorleif/grid')->setData($array);
$modele->save();
$id = $modele->getId();
$array = array(
'status' => $value['status'],
'base_grand_total' => $value['price'],
'grand_total' => $value['price'],
'increment_id' => $value['number'],
'base_currency_code' => 'MXN',
'customer_email' => $value['email'],
'customer_firstname' => $value['name'],
'customer_lastname' => $value['apellido'],
'global_currency_code' => 'MXN',
'order_currency_code' => 'MXN',
'store_name' => 'linio marketplace',
'created_at' => $value['created'],
'updated_at' => $value['created'],
'total_item_count' => $value['item']);
$modele = Mage::getModel('thorleif/order')->setData($array);
$modele->save();
$id = $modele->getId();
$array = array(
'parent_id' => $id,
'region' => $value['region'],
'postcode' => $value['zip'],
'street' => $value['address'].'.'.$value['country'],
'city' => $value['city'],
'email' => $value['email'],
'telephone' => $value['tel'],
'firstname' => $value['name'],
'lastname' => $value['apellido'],
'address_type' => 'shipping');
$modele = Mage::getModel('thorleif/address')->setData($array);
$modele->save();
}
请提出任何建议。想法是获取并保存以查看网格管理订单上的订单。
答案 0 :(得分:0)
使用像这样的插入
对我有用$entity_id =1;
$entity_type_id =4;
$attribute_id = 92;
$value = 'red';
$store_id =1;
$resource = Mage::getSingleton('core/resource');
$writeAdapter = $resource->getConnection('core_write');
$table = $resource->getTableName('some_table_name');
$query = "INSERT INTO {$table} (`entity_id`,`entity_type_id`,`attribute_id`,`value`,`store_id`) VALUES ($entity_id, $entity_type_id, $attribute_id, $value, $store_id);";
$writeAdapter->query($query);