Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Einfügen mehrer Bilder #439

Open
milch-shake opened this issue Jun 25, 2019 · 0 comments
Open

Einfügen mehrer Bilder #439

milch-shake opened this issue Jun 25, 2019 · 0 comments

Comments

@milch-shake
Copy link

milch-shake commented Jun 25, 2019

Hallo, ich lade eine XML Datei mit Artikeldaten und dort sind insgesamt 4 Bilder enthalten. Das Hauptbild und 3 Gallerie-Bilder. Leider werden 1) nicht alle Bilder im Artikel gespeichert und 2) die Gallerie gar nicht. Ich nutze Magento 1.9.1.0

    $tmpData = array();
    $sku = $item->sku->__toString();
    
    /** Order für Bilder erstellen */
    $imageFolder = $rootFile . '/media/werksraeder_tmp/' . $sku . '/'; 
    mkdir($imageFolder, 0755);
    
    /** Hauptbild */
    $bildname = basename($item->image_link->__toString());
    $mainImage = $imageFolder . $bildname;
    @file_put_contents($mainImage, file_get_contents($item->image_link->__toString()));
    
    if ($mainImage) {
        $tmpData['_media_image'][] = $mainImage;
        $tmpData['_media_target_filename'][] = $bildname;
        $tmpData['image'][] = $bildname;
        $tmpData['small_image'][] = $bildname;
        $tmpData['thumbnail'][] = $bildname;
        $tmpData['_media_position'][] = 1;
        $tmpData['_media_attribute_id'][] = 77;
        $tmpData['_media_is_disabled'][] = 1;
    }
    
    $counter = 1;
    
    foreach($item->zzzadditional_imagelinks as $image) {
        $basename = basename($image->__toString());
        $galleryImage = $imageFolder . $basename;
        @file_put_contents($galleryImage, file_get_contents($image->__toString()));
        
        $tmpData['_media_image'][] = $galleryImage;
        $tmpData['_media_target_filename'][] = $basename;
        $tmpData['image'][] = NULL;
        $tmpData['small_image'][] = NULL;
        $tmpData['thumbnail'][] = NULL;
        $tmpData['_media_position'][] = ++$counter;
        $tmpData['_media_attribute_id'][] = 77;
        $tmpData['_media_is_disabled'][] = 0;
        
    }`

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant