Я пытаюсь создать статью в magento на основе набора данных из системы erp. Пока что создаются работы только с одним оставшимся глюком. Я не могу устанавливать цены на группы и слезы.magento создание группы цена и уровень цена не сохраняется
Вот мой код:
protected function updatePrices(){
$groups = Mage::getModel('customer/group')->getCollection()->getAllIds();
if((float)$this->erpdata['grundpreis'] > 0.00){
$this->product->setPrice((float)$this->erpdata['grundpreis']);
}
if((float)$this->erpdata['shop']['art']['products_pseudoprices'] > 0.00){
$this->product->setMsrp((float)$this->erpdata['shop']['art']['products_pseudoprices']);
}
//preapre the price data for ranges
$prepareDatas = array();
if(count($this->erpdata['preisgruppen'])){
foreach($this->erpdata['preisgruppen'] as $group){
$dset = array('gruppe'=>0,'gp'=>0,'range'=>array());
foreach($group as $key=>$value){
if($key === 'gruppe'){
$dset['gruppe']= ((int)$value - (int)250);
}else if($key === 'grundpreis'){
$dset['gp'] = $value;
}else if(strpos($key,'preis_gruppe')!==false){
$ident = (int)str_replace('preis_gruppe','',$key);
if(!isset($dset['range'][$ident]) || !is_array($dset['range'][$ident])){
$dset['range'][$ident] = array();
}
$dset['range'][$ident]['price'] = $value;
}else if(strpos($key,'preis_range')!==false){
$ident = (int)str_replace('preis_range','',$key);
if(!isset($dset['range'][$ident]) || !is_array($dset['range'][$ident])){
$dset['range'][$ident] = array();
}
$dset['range'][$ident]['quantity'] = $value;
}
}
$prepareDatas[] = $dset;
}
}
//now process the stuff for each pricegroup to add it to the main article
$storeid = Mage::app()->getStore()->getWebsiteId();
$pricegroupdata = array();
$tiergroupdata = array();
foreach($prepareDatas as $prepareData){
//first set the Grundpreis
$pricegroupdata[] = array(
'website_id'=>$storeid,
'cust_group'=>$prepareData['gruppe'],
'price'=>(float)$prepareData['gp']
);
//now run through the groups if available
if(count($prepareData['range'])>0){
foreach($prepareData['range'] as $range){
$tiergroupdata[] = array(
'website_id'=>$storeid,
'cust_group'=>$prepareData['gruppe'],
'price'=>(float)$range['price'],
'price_qty'=>number_format((float)$range['quantity'], 4, '.','')
);
}
}
}
if(count($pricegroupdata)>0){
$this->product->group_price = $pricegroupdata;
}
if(count($tiergroupdata)>0){
$this->product->tier_price = $tiergroupdata;
}
}
Статья Цена устанавливается. Также стоимость. Но ни уровни, ни групповые цены не установлены или не обновлены. Что я делаю неправильно? Где я ошибаюсь?
всякая помощь приветствуется.
У меня нет идеи, почему я не могу создать слезы или групповые цены? –