2012-01-20 35 views
2

我正在使用數據泵,並且所有的都是goint,但我需要添加圖像處理器。到目前爲止沒有運氣。有人知道怎麼做嗎?這裏是docs。這是我工作的代碼。我沒有把VARS英寸Magento使用圖像插件的批量導入器(MAGMI)

require_once(MAGENTO."/magmi/integration/magmi_datapump.php"); 
class TestLogger{ 
    public function log($data,$type){ 
     $mess.="$type:$data\n"; 
    } 
} 
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport"); 
$dp->beginImportSession("default","create",new TestLogger()); 
$item=array(
          "type"=>"simple", 
          "sku"=>$sku, 
          "name"=>$p_name, 
          "short_description"=>$shortdesc, 
          "description"=>$longdesc, 
          "cost"=>$cost, 
          "price"=>$price, 
          "min_qty"=>0, 
          "qty"=>$stock, 
          "tax_class_id"=>2, 
          "status"=>2, 

          "attribute_set"=>$attribute_set, 
          "category_ids"=>implode(",",array_unique($cat_list)), 
          "manufacturer"=>$manufacturer 
         ); 
//This doesn't seem to be working. 
$item["image"]="http://images.domain.com/product_images".$image[0]; 

$item["store"]=""; 
$dp->ingest($item); 
$dp->endImportSession();        

現在我已經通過看,我看不出如何獲得其固定於插件的加載..任何想法? Tk

回答

2

所以我沒有能夠做到這一點..但我現在知道爲什麼..因爲我沒有使用用戶界面我不是固有的所有類,所以我不能使用itemprocessor和然後是圖像處理器,因爲它從中繼承。所以這裏是我如何解決它。在MAGMI通過數據泵傳輸數據之後,我只是重新列出了這個列表。這是如何

$imgAttrIds = array(79,80,81); 
$imageGalId = 82; 
$conn = Mage::getSingleton('core/resource')->getConnection('core_read'); 
$connW = Mage::getSingleton('core/resource')->getConnection('core_write'); 


if($image[0]!=''){ 
$image_file="http://domain.com/product_images".$image[0]; 
$param=array(); 
$config=array(); 


$p=Mage::getModel('catalog/product')->loadByAttribute('sku',$line[0]); 
$entity_id=$p->getId(); 
$insertData = array(); 
$skusToInsert = array(); 


for ($i = 0; $i <= count($image)-1; $i++) { 
    //there is a very nifty image sizer there so $params is a for that ;) 
    $param['to']="/media/catalog/product".$image[$i]; 
    echo function_supersizer($param,$config)."<br/>"; 
    if($i<=0){ 
     foreach($imgAttrIds as $img) {    
      $insertData[] = "(4, ".$img.", 0, ".$entity_id.", '".$image[$i]."')"; 
     } 
    } 
    $skusToInsert[] = "(".$imageGalId.", ".$entity_id.", '".$image[$i]."')"; 
} 
$sql = "INSERT INTO mag_catalog_product_entity_media_gallery (attribute_id, entity_id, value) VALUES ".implode(",",$skusToInsert).";"; 
$connW->query($sql); 
$sql = "INSERT INTO mag_catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) VALUES ".implode(",",$insertData).";"; 
$connW->query($sql); 

這工作..它適合我。只是做了15000個產品測試..但是..是原樣,對β先用等

乾杯-Jeremy

3

要使圖像處理器正常工作,您必須通過magmi配置UI將其添加到「默認」配置文件的選定插件列表中。

+0

好的..我想我知道我需要什麼。我需要將插件列在magmi/conf/plugins.conf中。是否有人有該文件的示例?我的是空的,我不確定我想要運行UI配置頁面,並冒着不妥的風險。 –

+0

如果您不想破壞任何東西,請在UI中創建一個新的magmi配置文件,並在此新配置文件中修改插件。如果此新配置文件被稱爲「測試」,例如: $ dp-> beginImportSession(「test 「,」創建「,新的TestLogger());使用它,而不是基本的默認配置文件 – dweeves

+0

@dweeves我有這個相同的問題,但不使用「默認」,圖像處理器已啓用和內部的配置。沒有錯誤。 –

2

jeremyBass_DC認爲你是錯誤的,dweeves是正確的。

您使用此:

$dp->beginImportSession("default","create",new TestLogger()); 

這意味着你使用的是 「默認」 配置文件。

您可以在這個網址配置此配置文件: http://www.yourweb.com/magmi/web/magmi.php

如果沒有圖像處理器,你可以下載插件手動 http://sourceforge.net/projects/magmi/files/magmi-0.7/plugins/individual/

要安裝,你必須把「itemprocessors」文件夾到 「magmi \ plugins \ base \ itemprocessors」

起初我遇到了和你一樣的問題,這種方式很好。

+0

嗨,歡迎來到SO! - 請在這個http://meta.stackexchange.com/questions/5029/are-taglines-signatures-disallowed快速窺視未來的帖子:) – Fluffeh

+0

什麼是http://www.yourweb.com/magmi /web/magmi.php鏈接在這裏..?只是一個重定向到laa土地?但我確實嘗試了調整,因爲你反饋的建議是......我可能不得不再次嘗試一下,看看是否有我輸入錯字或有什麼。 –