Magento 1.7 Mage::()->getModel() don't work
I have problem with save records in database using Mage::getModel in
module upgrade.
I'd like add affiliate programs to affiliateplus module table when my
module is installed. My module overwrite affiliateplus module.
In mysql4-upgrade-0.1.3-0.1.4.php I have code
$installer = $this;
$installer->startSetup();
$_programList =[
'affiliate'=>[
'program_id'=>1,
'name' =>'Program Afiliacyjny',
'created_date' =>date('Y-m-d'),
'status' =>1,
'expire_time'=>0,
'num_account'=>2,
'total_sales_amount' =>0.00,
'commission_type'=>'precentage',
'commission'=>1,
'discount_type'=>'precentage',
'discount' =>1,
'autojoin' =>1,
'scope' =>0,
'customer_groups' =>null,
'show_in_welcome' =>0,
'valid_from' =>null,
'valid_to' =>null,
'use_coupon' =>0,
'coupon_pattern'=>null ,
'affiliate_type'=>null ,
'description' =>'Program Afiliacyjny',
'conditions_serialized'
=>'a:6:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}',
'actions_serialized'
=>'a:6:{s:4:"type";s:40:"salesrule/rule_condition_product_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}',
'is_process' =>0,
'use_tier_config'=>0 ,
'max_level' =>0,
'tier_commission'=>null ,
'sec_commission' =>0,
'sec_commission_type'=>0 ,
'secondary_commission' =>0,
'sec_discount' =>0,
'sec_discount_type'=>null ,
'secondary_discount' =>0,
'customer_group_ids' =>'1',
'use_sec_tier' =>0,
'sec_tier_commission'=>null
],
['more elements...']
];
foreach($_programList as $_v){
$_program = Mage::getModel('affiliateplusprogram/program');
$_program->setData($_v);
$_program->save();
unset($_program);
}
$installer->endSetup();
I tryed also:
foreach inside loop and setData for each value.
setId() before save
When I display object after foreach it's object with only my values
without methods. Magento don't show errors and warnings. My module is
upgrade to good version but in database table is empty.
In all tutorials solve id simple Mage::getModel ->setData()->save()
No comments:
Post a Comment