Product Picture Migration into NOP

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
I am migrating data from another ecomm cart into NOP. The old system just stored paths to the images in the db, rather than storing the images in the db. I have successfully gotten the pictures loaded up into nop_pictures and nop_productpicture. When I run the site, the pictures are not showing up. Instead of the standard "no image available" I now get text that says "picture of [productname]", with no picture.

What could be wrong?

Here is my import code. (I wrote some sql code to put the old image path into my product short description temporarily to make the migration easier)


var products = ProductManager.GetAllProducts();

foreach (var product in products)
{
    
    if (! String.IsNullOrEmpty(product.ShortDescription))
    {
        var fpath = product.ShortDescription;
        
        var fileInfo = new FileInfo(fpath);
        var numBytes = fileInfo.Length;
        var fileExtension = fileInfo.Extension;
        var fileStream = new FileStream(fpath, FileMode.Open);
        var productPictureBinary = PictureManager.GetPictureBits(fileStream, (int)numBytes);
        fileStream.Close();

        var picture = PictureManager.InsertPicture(productPictureBinary, fileExtension, true);
      
        if (picture != null)
        {
            ProductManager.InsertProductPicture(product.ProductID, picture.PictureID, 1);
        }
    }
}
14 years ago
I just noticed that it is trying to display the image from http://localhost:1675/images/thumbs/0000103_125..jpg.

Where in the NOP code, and when in the process of loading product pictures are the thumbs created?
14 years ago
try
Libraries\Nop.BusinessLogic\Media\picturemanager.cs
12 years ago
Hello!

I'm having the issue also at the moment. Was it solved when the folder directory was changed?? Was the offer useful over the problem?

If someone please can inform me; it will be highly appreciated. Cheers.
12 years ago
I have the similar problem mentioned here. We imported a huge database with picture links on web into our database using file system instead database to store pictures. And now most of the products (when I browse) seem to lack pictures to be displayed both at end and fronend; and instead there's a text saying: picture of "..product name...".

Does anyone have an idea of how to fix this problem? The folders at NopCommercestore/images seem to be filling very fine and there is the place for pictures to be linked right?

Any help will be gratefully appreciated!

Thanks.
Emin
12 years ago
This worked for me.

'strPictureBinary is the value which should be inserted into the PictureBinary Field (No single quotes around the value)
Dim strPictureBinary As String = "0x" & System.BitConverter.ToString(ConvertImageFiletoBytes(strFilePath)).Replace("-", "")

    Public Function ConvertImageFiletoBytes(ByVal ImageFilePath As String) As Byte()
        Dim _tempByte() As Byte = Nothing
        If String.IsNullOrEmpty(ImageFilePath) = True Then
            Throw New ArgumentNullException("Image File Name Cannot be Null or Empty", "ImageFilePath")
            Return Nothing
        End If
        Try
            Dim _fileInfo As New IO.FileInfo(ImageFilePath)
            Dim _NumBytes As Long = _fileInfo.Length
            Dim _FStream As New IO.FileStream(ImageFilePath, IO.FileMode.Open, IO.FileAccess.Read)
            Dim _BinaryReader As New IO.BinaryReader(_FStream)
            _tempByte = _BinaryReader.ReadBytes(Convert.ToInt32(_NumBytes))
            _fileInfo = Nothing
            _NumBytes = 0
            _FStream.Close()
            _FStream.Dispose()
            _BinaryReader.Close()
            Return _tempByte
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.