Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Bilder im Shop

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Bilder im Shop
    Antwort #15 am: 04. Dezember 2015, 16:39:47
    wie viele maximal?
    Werbung / Banner buchen

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Bilder im Shop
    Antwort #16 am: 04. Dezember 2015, 16:45:26
    Ich sehe gerade das ist Wurst ... ich melde mich ...

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Bilder im Shop
    Antwort #17 am: 04. Dezember 2015, 17:22:01
    Also ZUERST den Shop wieder in den Originalzustand bringen! Also der Ordner original_images muss die Bilder enthalten, wo die Zuordnung products_id == Bildname nicht stimmt!

    Dann den Code ausführen:
    Code: PHP  [Auswählen]
    <?php
    require_once('includes/application_top.php');
    //get table products_images (contains additional images)
    $sql = "SELECT * FROM products_images";
    $res = xtc_db_query($sql);
    $products_additional_images = xtc_db_fetch_array($res);
    // get table products (first image there)
    $sql = "SELECT products_id, products_image FROM products";
    $res = xtc_db_query($sql);
    $products = xtc_db_fetch_array($res);
    // set dirs
    $dir_orig="images/product_images/original_images/";
    $dir_backup="images/product_images/original_images_backup/";
    // initialize variable
    $file_sql = '';
    // move original to backup dir
    rename($dir_orig,$dir_backup);
    // create original dir with correct permissions
    mkdir($dir_orig,0755);
    // copy the index.html
    copy ($dir_backup . 'index.html', $dir_orig . 'index.html');
    // loop over all products
    foreach ($products as $product) {
            // copy the first image of the product to new name
            $file = explode('_',$product['products_image']); //split id part of image from end part (0.jpg)
            copy ($dir_backup . $product['products_image'], $dir_orig . $product['products_id'] . '_' . $file[1]);
            // prepare sql
            $file_sql .= "UPDATE products SET products_image='" . $product['products_id'] . '_' . $file[1] . "' WHERE products_id = '" . $product['products_id'] . "'\n";
            // loop over whole table products_images to do the same stuff with the images there
            foreach ($products_additional_images as $add_image) {
                    if ($add_image['products_id'] === $product['products_id']) { // we found one
                            $file = explode('_',$add_image['image_name']); //split id part of image from end part (0.jpg)
                            copy ($dir_backup . $add_image['image_name'], $dir_orig . $add_image['products_id'] . '_' . $file[1]);
                            // prepare sql
                            $file_sql .= "UPDATE products_images SET image_name='" . $add_image['products_id'] . '_' . $file[1] . "' WHERE products_id = '" . $add_image['products_id'] . "' AND image_id = '" . $add_image['image_id'] . "'\n";
                    }
            }
            echo "<p>Product_ID: " . $product['products_id'] . "</p>\n";
    }
    $write = file_put_contents('images_fix.sql',$file_sql);
    if ($write ===false) {
            echo "<p>FEHLER BEIM SCHREIBEN DER SQL DATEI!</p>";
    } else {
            echo "<p>SQL Datei &quot;images_fix.sql&quot; im Shoproot erfolgreich erzeugt. ($write bytes)</p>";
    }
    ?>

    Jetzt hast Du einen Backup-ordner mit den unveränderten Dateien und im original_images liegen die richtigen umbenannten. Die Rechte auf dem Ordner sind auch schon gesetzt.

    Außerdem sollte jetzt im Shoproot eine SQL Datei liegen. Diese dann einfach in myphpadmin in die Datenbank füttern.

    DANACH SCRIPT UND SQL DATEI WIEDER LÖSCHEN!

    Wieder ungetestet, könnte noch einen Bug enthalten ...

    goiko

    • Frisch an Board
    • Beiträge: 55
    Re: Bilder im Shop
    Antwort #18 am: 07. Dezember 2015, 15:20:56
    Hallo,

    also bei mir im Shop war mittlerweile so ein durcheinander mit den Bildern, das ich am Wochenende alle Bilder gelöscht habe und diese neu eingegeben habe.
    Trotzdem vielen Dank für die schnelle und unkomplizierte Hilfe.
    Deine Arbeit konnte ich jetzt leider nicht testen. Vielleicht kann das noch jemand mit änlichen Proplemen.
    Du hast mir auf jeden Fall sehr geholfen.

    Gruß Goiko
    3 Antworten
    2486 Aufrufe
    20. Juni 2014, 23:27:29 von Matt
    3 Antworten
    2613 Aufrufe
    27. April 2014, 15:35:19 von noRiddle (revilonetz)
    1 Antworten
    623 Aufrufe
    20. Mai 2022, 22:47:31 von Die-3D-Techniker
    30 Antworten
    15389 Aufrufe
    18. August 2009, 13:03:48 von Tomcraft
               
    anything