0

For each product I want to know the local image path. I want to make a script and make my own images from an existing installation in my computer.

Is there a way to do it?

For my local development environment I cloned a remote db and I anonymized it. But I also want to replace the images with dummy ones as well. Is there a way to do this? An approach of mine is to:


$sql = "SELECT images from img_table";

$pdoConn = new PDO();

$stmt = $pdo->query($sql);
while ($row = $stmt->fetch()) {
    // create an img here with gd
}

DO you know how I can do this?

1
  • Product images are typically stored in the catalog_product_entity_media_gallerytable. This table contains the image records associated with each product.
    – Bushra
    Sep 22 at 20:49

1 Answer 1

1

These are following table and path where you can change the image path in Magento 2, product images are usually stored in database tables with actual file path references.

The main tables associated with object images are:

catalog_product_entity_varchar: This table stores attributes of varchar data type, including image attributes. The value column contains the file path of the image.

catalog_product_entity_media_gallery: This table stores information about the media gallery for products, including images, videos, and other media. It contains information about actual image files.

catalog_product_entity_media_gallery_value: This table associates images with specific products. It associates the product entity ID with the media gallery entry.

catalog_product_entity_media_gallery_value_to_entity: This table is used to associate media gallery entries with objects.

Please note that Magento uses a combination of file system storage and database references to manage images. The actual image files are stored in the pub/media/catalog/product directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.