[英]magento creating group price and tier price is not storred
I'm trying to create an article in magento to based on a dataset from an erp system. 我正在尝试基于erp系统中的数据集在magento中创建文章。 So far creating works with only one remaining glitch. 到目前为止,创作只剩下一个小故障。 I can't set group nor tear prices. 我不能组团,也不能撕价。
Here's my code: 这是我的代码:
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;
}
}
The Article Price is set. 设置商品价格。 Also the cost value. 还有成本价值。 But neither tier nor group prices are set or updated. 但是,没有设置或更新等级或组价格。 What am I doing wrong? 我究竟做错了什么? Where am I mistakin? 我在哪里混蛋?
every help is appreceated. 每一个帮助都是宝贵的。
Found the solution by just simply storing the fresh created product. 只需存储新创建的产品即可找到解决方案。 After that it worked without a problem, although I had to extend the object that was stored quite a bit. 在那之后它仍然没有问题,尽管我不得不扩展存储了很多对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.