2
votes

I am using the datapump and all is goint well but I need to add the imageprocessor. So far no luck. Anyone know how to do this? here is the docs . This is the code I have working. I didn't put the vars in.

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();                            

Now I have looked through the and I don't see how to get the plugin's loaded.. Any ideas on fixing it? Tk

3

3 Answers

3
votes

For the imageprocessor to work, you have to add it into the selected plugin list of your "default" profile via the magmi configuration UI.

2
votes

So I was not ever able to do it.. but I now know why too.. Because I'm not using the UI I don't inherent the all the classes and so I can't use the itemprocessor and then the image processor since it inherits from that. So here is how I worked around it. I just reloop over the list after MAGMI does it's thing thru the datapump. Here is how

$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);

This works.. it works well for me. Just did a test of 15,000 products.. but.. yeah as is, use on beta first etc.

Cheers -Jeremy

2
votes

jeremyBass_DC think you are wrong and dweeves is right.

You are using this:

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

This means that you are using the "default" profile.

You can config this profile at this url: http://www.yourweb.com/magmi/web/magmi.php

If there is no image processor you can download the plugin manually http://sourceforge.net/projects/magmi/files/magmi-0.7/plugins/individual/

To install you have to put the "itemprocessors" folder into "magmi\plugins\base\itemprocessors"

At first I got the same problem as you, and this way works fine.