Created
February 7, 2019 14:22
-
-
Save migcosta/92f1dfe70bda5f3c6950a82d5b7008df to your computer and use it in GitHub Desktop.
magento 2.3 migration images issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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