• Welcome to KonaKart Community Forum. Please login or sign up.
 

Inserting Products with AdminIf.insertProduct() does not include images

Started by markb, April 27, 2014, 02:42:42 pm

Previous topic - Next topic

markb

While I am able to insert a new product programmatically using the AdminIf.insertProduct() method, there appear to be no product images uploaded, even though I am setting them with AdminProduct.setImage(fullPathToImage). When adding products from the konakartadmin Products page, there is the "Browse" button used to select the image file, and then the "Upload" button. Does this imply there is a secondary upload step needed when adding products programmatically? I have followed the example shown in apiexample file InsertProduct.java.

markb

I checked the log file, too, and there is no error indicating why the product image was not uploaded.

markb

After looking at the product_image column values in the products table, I see that the path I provided is not correct, and that a subsequent upload is needed.

Can anyone point me to an example of how to do that using the Konakart API, please?

ming

People use images in a variety of different ways with KonaKart but if you want to match the way the Admin App handles them (which is probably a good idea so that you can see and update the images within the Admin App later) what I suggest is to look at the columns on the products table that are set when you upload an image for a new product.   Note in particular the product_uuid and product_image_dir.

If coding the upload these utilities might be useful:

product.setUuid(com.konakart.util.Utils.getUUID());

// e.g. prod/0/7/1/2/
String imgPath = com.konakart.util.Utils.constructProductImageDirName(uuid, /* dirName */"prod", /* depth */  4);
product.setImageDir(imgPath);


(Note how the imgPath directories are derived from the first n digits of the UUID)

You may also like to use the image scaling API:  (called scaleImage() on KKAdminIf)

http://www.konakart.com/javadoc/admin/com/konakartadmin/appif/KKAdminIf.html#scaleImage(java.lang.String, com.konakartadmin.app.AdminScaleOptions)


Abhed

Hello Markb,

Was you able to get this done ? I am working on the same scenario to set images to a product through SOAP services. And those images should be later visible when accessing the product from konakart admin view.

I am clear about setting related file path and directory path in the product related table through the SOAP service. But I am not able to find related API to actually upload the image (which konakart webapp stores at /prod folder within webapp) . I am also wondering that I should not generate image directory path and it should be returned from the upload API.

Please provide your inputs or a code snippet will be very helpful.

Thanks in advance!

regards,
Abhed

ming

Have you looked at the scaleImage call on http://www.konakart.com/javadoc/admin/com/konakartadmin/appif/KKAdminIf.html

If you create an image for a product by uploading it in the Admin App you will then be able to see which product attributes to populate in order to match that - which will allow you to see your loaded images in the Admin App.

Abhed

Hello Ming,

Please correct me, if I am incorrect at any point.
To display an image in konakart front-end, I need to handle 2 things: (1) upload the image at KonaKart\webapps\konakart\images\prod\  (2) set the path of uploaded images to product's tables in konakartadmin. Path here should refer to 'prod/' folder in point-1.

Now the suggested method "scaleImage" applies scaling and copies the file from source to target folder. So should I use this method to achieve above point-1 ? How should I generate folder structure within 'prod/' folder for different products ?

Once I achieve point-1 then I know the related properties to set for image path in admin product object.

Please advice.

regards,
Abhed

ming

A new API call was added in the v7.3.0.0 Enterprise release that might help with loading images programmatically:

Take a  look at the addImage call (http://www.konakart.com/javadoc/admin/com/konakartadmin/appif/KKAdminIf.html#addImage(java.lang.String, com.konakartadmin.app.AdminImageOptions))  on KKAdminIf