Jump to content

Upload images from a webservice


tarek.fellah

Recommended Posts

I uploaded my product images as follow: an image with 1234 id will be uploaded in img/p/1/2/3/4/1234-large_default.jpg when i viewed the product information related to the image, a default file (product image unavailable) is displayed.

my code for adding images to database

$res = "insert into "._DB_PREFIX_."image (`id_product`,`position`,`cover`) values
(".$id_product.",1, 1)";
if (!Db::getInstance()->execute($res))
die('Erreur etc.');
$id_image = Db::getInstance()->Insert_ID();

$res = "insert into "._DB_PREFIX_."image_lang (`id_image`,`id_lang`) values   (".$id_image.", 1)";
if (!Db::getInstance()->execute($res))
die('Erreur etc.');

$res = "insert into "._DB_PREFIX_."image_lang (`id_image`,`id_lang`) values (".$id_image.", 2)";
if (!Db::getInstance()->execute($res))
die('Erreur etc.');

$stmt = "insert into "._DB_PREFIX_."image_shop(`id_image`,`id_shop`,`cover`) values (".$id_image.",1,1)";
$folders = str_split($id_image);
$i = 0;
$base_uri ='var/www/autospareparts.se.com/img/p/';
$folders = str_split($id_image);
$i = 0;
$base_uri ='/var/www/autospareparts.se.com/img/p/';
while( $i <sizeof($folders) )
{


$base_uri .= $folders[$i].'/';


if($i==(sizeof($folders) -1))
{if(!is_dir( $base_uri))
if(!mkdir($base_uri, 0777, true))
die('Echec lors de la création des répertoires...');
download_remote_file('http://pic1.aldoc.eu/PicData  /'.$pic,$base_uri.$id_image.'large_default.jpg' );

}
//fin else
$i++;
}

 

I showed the code of mytheme/product.tpl i found

$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')

 

which return img/p/fr-default-large_default.jpg

Can you tell me what's wrong? Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...