News:

Support the VirtueMart project and become a member

Main Menu

[Solved] I have a 90K product issue with whitespace......

Started by kittmaster, September 17, 2015, 03:22:30 AM

Previous topic - Next topic

kittmaster

I'm using an automated script to create the file names and I just found a critical error in it. Here is an example of my media file name:

14100XPERCENTXOFXDISINXXYOUXARMANDOX127X1992X7311360X1327634828X1309729597X226-FRONT COVER_90x90.jpg

As you can see "FRONT COVER" has a space which I forgot to use an underscore or hyphen in the name.

Here is the code I'm using for the thumbnail creation:



<?php 
                $db 
JFactory::getDbo(); 
                
$db->setQuery('SELECT m.file_url_thumb FROM #__virtuemart_product_medias pm,#__virtuemart_medias m WHERE (pm.virtuemart_product_id='.$item->virtuemart_product_id.')AND(pm.virtuemart_media_id=m.virtuemart_media_id)'); 
                
$res $db->LoadResult(); 
echo "<img src=\"$res\">";
?>




What I'm getting is:

htxp://wxw.mysite.blah/14100XPERCENTXOFXDISINXXYOUXARMANDOX127X1992X7311360X1327634828X1309729597X226-FRONT

because of the space breaking the link image.

Anyone have a way to reparse the file path to deal with the space in it? There is no way in the world I can redo all the products and media because it will break my previous invoices and history order etc.

I need to find a way to deal with this but not sure how to handle it.

Can anyone provide some guidance on how to retool this?

Thanks in advance.

Chris


balai

Why don't you run an update query for that table?

kittmaster

Because all of the file names have the space so it would still be a mismatch.

balai


kittmaster

That worked great, took a minute to figure out the best way to do it, but this is my solution and it works great. This is being used in a template override so it can't be overwritten by the core updates.


<td align="left" colspan="2" >
<?php 
                $db 
JFactory::getDbo(); 
                
$db->setQuery('SELECT m.file_url_thumb FROM #__virtuemart_product_medias pm,#__virtuemart_medias m WHERE (pm.virtuemart_product_id='.$item->virtuemart_product_id.')AND(pm.virtuemart_media_id=m.virtuemart_media_id)'); 
                
$res $db->LoadResult();
rawurlencode('$res');
                echo 
"<img src=\"http://www.test.example.com/$res\">";
//echo "<img src=\"$res\">"; // Original parse from another virtuemart 2 thread
?>

</td>


Thanks for the pointer and the help.

Chris