2014-03-31 2 views
1

의 그룹 및 계층 가격을 가져 오기 위해 magmi를 사용 하려는데 그룹에 로그인하지 않았으며 내 CSV 헤더의 형식 또는 위치를 모르겠습니다.Magmi : 가져 오기 "Not Logged In"가격

magmi와 그룹 및 계층 가격 가져 오기를 모두 (sku,price,tier_price:_all_), 없음 (sku,group_price:None,tier_price:None) 및 기타 사용자 지정 그룹에 성공적으로 사용했습니다. A (sku,group_price:A,tier_price:A), B() 등이있다.

로그인하지 않은 형식 일뿐입니다. 알아낼 수 없으며 documentation에있는 항목을 찾을 수없는 것 같습니다.

여기까지 제가 시도한 내용입니다.

  • sku,group_price:NOT LOGGED IN,tier_price:NOT LOGGED IN
  • sku,group_price:'NOT LOGGED IN',tier_price:'NOT LOGGED IN'
  • sku,group_price:_not_,tier_price:_not_
  • sku,group_price:General,tier_price:General

어떤 아이디어가?

+0

Magento 버전, Magento 버전? – Axel

+0

Magento : 1.12.0.2, Magmi : v0.7.17a, 티어 가격 수입 v0.0.9a, 그룹 가격 수입 v0.0.1 – njm5785

답변

0

위의 csv 형식으로 계층 적 가격 책정 magmi 플러그인이 제대로 작동한다는 것을 알았습니다. 원래 코드는 약간의 코드 변경으로 작동하지만 그 다음에는 업데이트를 확인하기로 결정했습니다.

검색하는 동안 그룹 가격 인보이스 용 대체 magmi 플러그인을 찾았습니다.

magmi/plugins/extra/itemprocessors/groupprice 폴더의 현재 파일을 one으로 바꿉니다.

자세한 내용을 보려면 website입니다.

+0

예 작품입니다 .. 디렉토리 생성 /var/www/html/../magmi/plugins/extra/itemprocessors/groupprice이 grouppriceprocessor.php를이 디렉토리에 놓고 magmi에서이 프로파일을 선택하십시오 .. group_price : general, group_price :이 둘은 csv 파일의 헤더이며이 값을 넣으면 작동합니다 .. thanks –

3
yes it is works.. create directory /var/www/html/../magmi/plugins/extra/itemprocessors/groupprice 
put this grouppriceprocessor.php on this directory , 
select this profile in magmi .. group_price:NOT LOGGED IN 
this is header in csv file put value for this and it works .. 

code of grouppriceprocessor.php 

    <?php 
/** 
* Class Tier price processor 
* @author dweeves 
* 
* This imports tier prices for columns names called "group_price:" 
*/ 
class GrouppriceProcessor extends Magmi_ItemProcessor 
{ 
    protected $_tpcol=array(); 
    protected $_singlestore=0; 
    protected $__pricescope=2; 

    public function getPluginInfo() 
    { 
     return array(
      "name" => "Group price importer", 
      "author" => "Dweeves,bepixeld,Jason", 
      "version" => "0.0.1", 
      ); 
    } 

    /** 
    * you can add/remove columns for the item passed since it is passed by reference 
    * @param Magmi_Engine $mmi : reference to magmi engine instance (convenient to perform database operations) 
    * @param unknown_type $item : modifiable reference to item before import 
    * the $item is a key/value array with column names as keys and values as read from csv file. 
    * @return bool : 
    *  true if you want the item to be imported after your custom processing 
    *  false if you want to skip item import after your processing 
    */ 



    public function processItemAfterId(&$item,$params=null) 
    { 

     $pid=$params["product_id"]; 

     $tpn=$this->tablename("catalog_product_entity_group_price"); 
     $tpcol=array_intersect(array_keys($this->_tpcol),array_keys($item)); 
     //do nothing if item has no group price info or has not change 
     if(count($tpcol)==0 ) 
     { 
      return true; 
     } 
     else 
     { 

     //it seems that magento does not handle "per website" tier price on single store deployments , so force it to "default" 
      //so we test wether we have single store deployment or not. 
      //bepixeld patch : check pricescope from general config 
      if($this->_singlestore==0 && $this->_pricescope!=0) 
      { 
      $wsids=$this->getItemWebsites($item); 
      } 
      else 
      { 
      $wsids=array(0); 
      } 
      $wsstr=$this->arr2values($wsids); 
      //clear all existing tier price info for existing customer groups in csv 
      $cgids=array(); 
      foreach($tpcol as $k) 
      { 
       $tpinf=$this->_tpcol[$k]; 
       if($tpinf["id"]!=null) 
       { 
        $cgids[]=$tpinf["id"]; 
       } 
       else 
       { 
        $cgids=array(); 
        break; 
       } 

      } 

      //if we have specific customer groups 
      if(count($cgids)>0) 
      { 
       //delete only for thos customer groups 
       $instr=$this->arr2values($cgids); 

       //clear tier prices for selected tier price columns 
       $sql="DELETE FROM $tpn WHERE entity_id=? AND customer_group_id IN ($instr) AND website_id IN ($wsstr)"; 
       $this->delete($sql,array_merge(array($pid),$cgids,$wsids)); 
      } 
      else 
      { 
       //delete for all customer groups 
       $sql="DELETE FROM $tpn WHERE entity_id=? AND website_id IN ($wsstr)"; 
       $this->delete($sql,array_merge(array($pid),$wsids)); 
      } 
     } 

     foreach($tpcol as $k) 
     { 

     //get tier price column info 
      $tpinf=$this->_tpcol[$k]; 
      //now we've got a customer group id 
      $cgid=$tpinf["id"]; 
      //add tier price 
      $sql="INSERT INTO $tpn 
      (entity_id,all_groups,customer_group_id,value,website_id) VALUES "; 
      $inserts=array(); 
      $data=array(); 

      if($item[$k]=="") 
      { 
      continue; 
      } 
      $tpvals=explode(";",$item[$k]); 

      foreach($wsids as $wsid) 
      { 
       //for each tier price value definition 
       foreach($tpvals as $tpval) 
       { 
        $tpprice=str_replace(",",".",$tpval); 
        if($tpprice=="") 
        { 
         continue; 
        } 
        if(substr($tpprice,-1)=="%") 
        { 
         //if no reference price,skip % tier price 
         if(!isset($item["price"])) 
         { 
          $this->warning("No price define, cannot apply % on group price"); 
          continue; 
         } 
         $fp=(float)(str_replace(",",".",$item["price"])); 
         $pc=(float)(substr($tpprice,0,-1)); 
         $m=($pc<0?(100+$pc):$pc); 
         $tpprice=strval(($fp*($m))/100.0); 
        } 
        $inserts[]="(?,?,?,?,?)"; 
        $data[]=$pid; 
        //if all , set all_groups flag 
        $data[]=(isset($cgid)?0:1); 
        $data[]=(isset($cgid)?$cgid:0); 
        $data[]=$tpprice; 
        $data[]=$wsid; 
       } 
      } 
      if(count($inserts)>0) 
      { 
      $sql.=implode(",",$inserts); 
      $sql.=" ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)"; 
      $this->insert($sql,$data); 
      } 
     } 
     return true; 
    } 

    public function processColumnList(&$cols,$params=null) 
    { 
     //inspect column list for getting tier price columns info 
     foreach($cols as $col) 
     { 
      if(preg_match("|group_price:(.*)|",$col,$matches)) 
      { 
       $tpinf=array("name"=>$matches[1],"id"=>null); 

       //if specific tier price 
       if($tpinf["name"]!=="_all_") 
       { 
        //get tier price customer group id 
        $sql="SELECT customer_group_id from ".$this->tablename("customer_group")." WHERE customer_group_code=?"; 
        $cgid=$this->selectone($sql,$tpinf["name"],"customer_group_id"); 
        $tpinf["id"]=$cgid; 
       } 
       else 
       { 
        $tpinf["id"]=null; 
       } 
       $this->_tpcol[$col]=$tpinf; 
      } 
     } 
     return true; 
    } 

    public function initialize($params) 
    { 
    $sql="SELECT COUNT(store_id) as cnt FROM ".$this->tablename("core_store")." WHERE store_id!=0"; 
    $ns=$this->selectOne($sql,array(),"cnt"); 
    if($ns==1) 
    { 
     $this->_singlestore=1; 
    } 
    //bepixeld patch : check pricescope from general config 
    $sql = "SELECT value FROM ". $this->tablename('core_config_data') ." WHERE path=?"; 
    $this->_pricescope = intval($this->selectone($sql, array('catalog/price/scope'), 'value')); //0=global, 1=website  

    } 
} 




thanks 
관련 문제