Hi everybody.
I need a external link for downloading image on a opencart site.
Everything work as I hope. The products created in opencart as quickly as I create a new product on dolibarr.
And my php script for downloading the images that I uploaded in a specific directory and integrate them into the product works very well…
Here what I need is have I link like http://mysite.com/images/ISBN.jpg
Or any other option. Is it possible?
Hello
How did you get opencart to match the products in dolibarr?
With php scripts and some plugins and some shell scripts on my own server
Sounds complicated… was hoping there was an easier way of making the two platforms talk.
Dolibarr is too slow as an operating e-store type interface.
Images are stored in their own folders in the /documents/produit/ folder. Would that not work for you?
Hello again
Which OpenCart version do you use?
Could you possibly assist in explaining which scripts/extensions you found to work between the two platforms?
Hello. I am not at home, I’ll explain here as quickly as possible
First of all in installed these two extensions. CSV Product Import (ver.4.3.1) and Task Scheduler (ver.2.3.0) from ka-station.com
And then wrote this script:
<?php
// pirtuk.fr
$db_record = 'llx_product'; $where = 'WHERE 1 ORDER BY 1';
$csv_filename = 'gestionexport.csv';
$hostname = "localhost";
$user = "user";
$password = "Pass123";
$database = "dbase";
$imgurl = '"http://cdn.pirtuk.fr/images/';
$scripturl = 'http://cdn.pirtuk.fr/lib/';
mysql_connect($hostname, $user, $password) or die('Could not connect: ' . mysql_error()); mysql_select_db($database) or die ('Could not select database ' . mysql_error());
$csv_export = '';
$query = mysql_query("SELECT * FROM ".$db_record." ".$where);
$field = mysql_num_fields($query);
$imgurltitle = "imageurl";
for($i = 0; $i < $field; $i++) {
$csv_export.= mysql_field_name($query,$i).';';
}echo "";
$csv_export.= $imgurltitle. "\n";
while($row = mysql_fetch_array($query)) {
for($i = 0; $i < $field; $i++) {
$csv_export.= '"'.$row[mysql_field_name($query,$i)].'";';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $scripturl . "getimagefromdol.php?" .$row['ref']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
$csv_export.= $imgurl .$row['ref'].'.jpg"'."\n";
}
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=".$csv_filename."");
echo($csv_export);
?>
the content of getimagefromdol.php is:
<?php
$dossierpublic = "/home/pirtuk/domains/cdn.pirtuk.fr/public_html/images/";
$dossierdolibarr = "/home/pirtuk/domains/gestion.pirtuk.fr/public_html/documents/produit/";
$extension = ".jpg";
$getsku = $_SERVER['REQUEST_URI'];
$getsku = substr($getsku,25);
foreach(glob($dossierdolibarr . $getsku.'/*'.$extension) as $filename){
copy($filename, $dossierpublic . $getsku . $extension);
}?>
And then i download a csv file with this commande:
wget http://cdn.pirtuk.fr/lib/export.php
I do the reste with the plugin options and cron. Good luck