Skip to content

Instantly share code, notes, and snippets.

@migcosta
Created February 7, 2019 14:22
Show Gist options
  • Save migcosta/92f1dfe70bda5f3c6950a82d5b7008df to your computer and use it in GitHub Desktop.
Save migcosta/92f1dfe70bda5f3c6950a82d5b7008df to your computer and use it in GitHub Desktop.
magento 2.3 migration images issues
<?php
/**
* I faced a strange issue while migrating a magento 2.3 from a server to another.
* some of the product images where in a uppercase folder on the server and on a lowercase on the db
* the fix was to create links...
*/
//get the folders list from [magento root]/apps/magento/htdocs/pub/media/catalog/product
$folders = ["A","B","C","d","e","f","G","h","i","J","k","l","M","n","o","P","r","s","T","u","V","w","y"];
foreach( $folders as $folder )
{
$path = '[magento root]/apps/magento/htdocs/pub/media/catalog/product/'.$folder;
$dirs = array_filter(glob($path.'/*'),'is_dir');
foreach( $dirs as $dir )
{
$pieces = explode('/',$dir);
$folderLetter = end($pieces);
if( ctype_upper( $folderLetter ) )
{
echo " ln -s $path/$folderLetter $path/".strtolower( $folderLetter )." \n";
}
else
{
echo " ln -s $path/$folderLetter $path/".strtoupper( $folderLetter )." \n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment