php - Magento xml importing - pictures are not imported -
i managed script importing products mapping of fields xml working.(magento xml import mapping).
i use magmi importer, here link magmi image attributes processor plugin (as discovered later) mandatory import pictures url: http://wiki.magmi.org/index.php?title=image_attributes_processor
but can't import pictures (link picture in xml url).
one product xml:
<izdelek> <st>1</st> <izdelekid>75</izdelekid> <izdelekime>ati radeon 102 - b62902 (b)</izdelekime> <izdelekpodnaslov>256 mb, dms - 59</izdelekpodnaslov> <izdelekopis></izdelekopis> <izdelekkategorija>komponente</izdelekkategorija> <izdelekdodatenopis> grafična kartica omogoča razširjeno namizje na dveh ekranih (dve različni sliki)! low profile - namenjena izključno sff računalnikom! </izdelekdodatenopis> <zadnja_osvezitev>16/08/2015</zadnja_osvezitev> <url>http://www.bbt.si/ati-radeon-102-b62902-b</url> <garancija>6 mesecev</garancija> <opis>pcie</opis> <slike> <slika1> http://www.bbt.si/modules/uploader/uploads/s_product/pictures/crop1/graficna-kartica-ati-102-b62902.jpg </slika1> </slike> <cena>12.20</cena> <cenabrezddv>10.00</cenabrezddv> <zaloga>več na zalogi</zaloga> </izdelek>
need advice wrong code:
<?php $spisekkategorij = array( 'komponente' => '738', 'prenosniki' => '742', 'monitorji' => '737', ); class testlogger { /** * logging methos * * @param string $data * : log content * @param string $type * : log type */ public function log($data, $type) { echo "$type:$data\n"; } } // setup include path's set_include_path('magmi' . path_separator . 'magmi/inc' . path_separator . 'magmi/integration/inc' . path_separator . 'magmi/engines'); // end include path's require_once("magmi_datapump.php"); // call datapump $dp = magmi_datapumpfactory::getdatapumpinstance("productimport"); $dp->beginimportsession("123", "create"); // "default" - name of profile , "create" - want create , update items $file = "test.xml"; $microline = new simplexmlelement($file, null, true); // load xml foreach ($microline $item) { $izdelek = ((string) $item->izdelekkategorija); $kategorija = (($spisekkategorij[$izdelek]) ? $spisekkategorij[$izdelek] : $kategorija); $newproductdata = array( "sku" => (string) $item->izdelekid .= ' abbt', "name" => (string) $item->izdelekime, 'price' => ((real) $item->cenabrezddv), 'description' => (string) $item->izdelekopis . (string) $item->izdelekdodatenopis, 'short_description' => (string) $item->izdelekdodatenopis, 'diagonala_rshop' => (string) $item->velikost_zaslona, 'procesor_rshop' => (string) $item->procesor, 'ram_rshop' => (string) $item->ram, 'hdd_rshop' => (string) $item->disk, 'operacijski_rshop' => (string) $item->licencna_nalepka, 'locljivost_rshop' => (string) $item->locljivost, 'grafika_rshop' => (string) $item->grafika, "attribute_set" => "test", "store" => "rshop", "category_ids" => $kategorija, ); $newproductdata["image"] = '+' . (string) $item->slike->slika1; // + show picture, - dont show picture $newproductdata['small_image'] = '+' . (string) $item->slike->slika1; // small img $newproductdata['thumbnail'] = '+' . (string) $item->slike->slika1; echo $izdelek; echo $kategorija; echo $slika; echo '<pre>'; print_r($newproductdata); echo '</pre>'; $dp->ingest($newproductdata); echo '' . ' mem:' . memory_get_usage() . " ... done! <br />\n"; //memory usage check } unset($microline); $dp->endimportsession(); // end import
i quick ask question ... problem magmi configuration solution is:
- enable magmi image attributes processor plugin
use "default" profile with
$dp->beginimportsession("123", "create");
(123 wrong magmi profile) right line must be:
$dp->beginimportsession("default", "create");
Comments
Post a Comment