2014-01-15 40 views
0

我想創建一個基於erp系統數據集的magento文章。 到目前爲止只有一個剩餘的故障創建工程。 我不能設置組或撕裂價格。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; 
     } 
    } 

文中的價格設置。 也是成本價值。 但是沒有設置或更新層級和組的價格。 我在做什麼錯? 我在哪裏誤會?

每一個幫助都是安裝的。

+0

沒有人知道我爲什麼不能創造眼淚或團體價格嗎? –

回答

0

只需簡單地存儲新鮮創建的產品即可找到解決方案。 之後,它的工作沒有問題,雖然我不得不擴展存儲相當多的對象。