I started to move my library from Coppermine Gallery to Phoca Gallery with sale of photos, about 28,000 images, http://www.d70.ch
Following the initial tests and if I understand correctly, you must create a single VM product for each photo for sale.
I did not find a script to create the products and I write a script in PHP.
Do you have information and comment to make.
Thank you
Ph.Dougoud
d70 photographie
Virtemart Product Creation
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Virtemart Product Creation
Hi, yes, you need to create a product id like image id For now I don't know any such script to make it automatically.
But I think,yes this can be done through some sql script, e.g. select id from product and if the id is the same like image in the gallery, then paste this id to the phoca gallery vm id column.
Jan
But I think,yes this can be done through some sql script, e.g. select id from product and if the id is the same like image in the gallery, then paste this id to the phoca gallery vm id column.
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 12
- Joined: 18 Apr 2011, 07:38
Re: Virtemart Product Creation
Hi,
I wrote a script in php with SQL query. It works but it is not user friendly.
I'll pass it.
You can use it and make comments.
This is my first program in PHP, a few years ago I used COBOL
so I'm not an expert on web languages
Best regards
Philippe
I wrote a script in php with SQL query. It works but it is not user friendly.
I'll pass it.
You can use it and make comments.
This is my first program in PHP, a few years ago I used COBOL
so I'm not an expert on web languages
Best regards
Philippe
Code: Select all
<?php
//**********************************
// nom : PhDCreateProduct.php
// description : Crée un produit VM par photo d'un album
// paramètre album, et catégorie du produit
// ***********************************
$album = $_GET['album'];
$cat_id= $_GET['catid'];
include("_connexion.php");
// function
function createProduct($titreAlbum, $album, $cat_id)
{
$pathPhocaGallery="http://www.d70.ch/images/phocagallery";
$insert="INSERT INTO jos_vm_product ".
"SET vendor_id = '1', ".
"product_parent_id = '0', ".
"product_sku = '".createNom($album['title'])."' , ". // nom de l'image
"product_s_desc = '".$titreAlbum." - ".createNom($album['title'])."' , ". // nom de l'image
"product_desc = '".createDesc($titreAlbum, createNom($album['title']))."' , ". // Description de l'album et nom de l'image
"product_thumb_image = '". $pathPhocaGallery."/".calcPathThumbs($album['filename'])."' ,".
"product_full_image = '". $pathPhocaGallery."/".$album['filename']."',".
"product_publish = 'Y', ".
"product_weight = '0', ".
"product_weight_uom = '', ".
"product_length = '0', ".
"product_width = '0', ".
"product_height = '0', ".
"product_lwh_uom= 'pouces', ".
"product_url = '', ".
"product_in_stock = '0', ".
"product_available_date = '0', ".
"product_availability= '24h.gif', ".
"product_special = 'N', ".
"product_discount_id = '0', ".
"ship_code_id = '0', ".
"product_name = 'Vente de photo de d70', " .
"product_sales = '0', ".
"attribute = 'Format,10x15[=3.24],13x18[=4.62],20x30[=18.51];Finition,Brillant,Semi mat', ".
"custom_attribute = '', ".
"product_tax_id = '3', ".
"product_unit = 'pièce', ".
"product_packaging = '0', ".
"child_options = 'N,N,N,N,N,Y,20%,10%,', ".
"quantity_options = 'none,0,0,1', ".
"child_option_ids = '', ".
"product_order_levels = '0,0'" ;
$resultInsert = mysql_query($insert) or die (mysql_error());
$vm_productID=mysql_insert_id();
insertTableConnexe($cat_id, $vm_productID);
return $vm_productID ;
}
// enlève le terne web dans le nom du fichier
function createNom($nom)
{
$nom=strtoupper($nom);
$pos=strpos($nom, "-WEB");
if ($pos)
{
$result=substr($nom, 0,$pos).substr($nom, $pos+4);
}
else
{
$result=$nom;
}
return $result;
}
function createDesc($description, $nom)
{
$description=strtolower(substr($description,0,1) ).substr($description,1);
$resultat="Photo ©Ph. Dougoud - d70 photographie : ". $description." - ".$nom;
return $resultat;
}
function calcPathThumbs($pathFull)
{
$pos=strrpos($pathFull,"/");
$path=substr($pathFull,0, $pos)."/vm/" ;
$nom=substr($pathFull,$pos+1) ;
$nom=strtoupper($nom); // le nom en majuscule
$pos=strpos($nom, "-WEB");
if($pos)
{
$nom=substr($nom, 0,$pos)."-vm".substr($nom, $pos+4);
}
$pathFull=$path.$nom;
return $pathFull ;
}
echo $gauche.$droite;
echo "<br />";
function insertTableConnexe($catproductID, $productID)
{
$insert="INSERT INTO jos_vm_product_category_xref ".
" SET category_id = '". $catproductID."' , ".
"product_id = ". $productID." , ".
"product_list = 1" ;
$resultInsert = mysql_query($insert) or die (mysql_error());
$insert="INSERT INTO jos_vm_product_price ".
"SET product_id = '". $productID."' , ".
"product_price = '3.24', ".
"product_currency = 'CHF', ".
"product_price_vdate = 0, ".
"product_price_edate = 0, ".
"cdate = '1303823812', ".
"mdate ='1303823812', ".
"shopper_group_id = 5" ;
$resultInsert = mysql_query($insert) or die (mysql_error());
}
// *****************************************************
$conn = mysql_connect ($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass'])
or die ("Connexion au serveur impossible !");
$db= mysql_select_db($CONFIG['dbname'])
or die ("Connexion à la base impossible !");
// lecture du titre de l'album
$sql = "SELECT `id`,`title` FROM `jos_phocagallery_categories` WHERE `id` = '$album' ";
$result = mysql_query($sql);
if (!$result)
{
$message = 'Requête invalide : ' . mysql_error() . "\n";
$message .= 'Requête complète : ' . $sql;
die($message);
}
$row = mysql_fetch_row($result);
$titreAlbum=$row[1];
echo "Affiche de l'album n° = ";
echo $row[0];
echo " Titre : " ;
echo $titreAlbum ;
echo "<br><br>" ;
mysql_free_result($result);
// sélectionne toutes les photo d'un album sans produit VM
if ($album == 0 )
{
echo "Il n'y a pas d'album -->";
echo $album ;
echo"<br>";
exit ;
}
$sql = "SELECT * FROM jos_phocagallery WHERE catid = ".$album." AND vmproductid = 0 ";
$result = mysql_query($sql);
if (!$result)
{
$message = 'Requête invalide : ' . mysql_error() . "\n";
$message .= 'Requête complète : ' . $sql;
die($message);
}
// pour chaque photo de l'album, un produit VM est créé
while ($album = mysql_fetch_assoc($result)){
echo $album["id"];
echo " -- ";
echo $album["catid"];
echo " -- ";
echo $album["title"];
echo " -- ";
echo $album["filename"];
echo " -- ";
echo $album["vmproductid"] ;
echo " -- ";
$vmproduct=createProduct($titreAlbum, $album, $cat_id);
echo "Le produit : ";
echo $vmproduct;
echo " a été créé ";
echo " -- ";
$update="UPDATE jos_phocagallery ".
"SET vmproductid = ".$vmproduct." ".
"WHERE id = ".$album["id"];
$resultUpdate = mysql_query($update)
or die(mysql_error());
echo " -- Lien MV et Phoca créé !";
echo "<br>";
}
mysql_free_result($result);
// Déconnexion
mysql_close();
exit;
?>
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Virtemart Product Creation
Hi, thank you, Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 1
- Joined: 03 Jun 2011, 01:08
Re: Virtemart Product Creation
I'm interested in porting my hobby website over to Joomla 1.6.3+ and my cmpg 1.4.4 and all the information about each photo and if possible the comments over to Phoca and possibly VirtueMart. The PHP SQL Query script presented looks interesting has anyone had a chance to use it with Joomla 1.6 and the newest phoca gallery?
Thanks!
Thanks!
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Virtemart Product Creation
Hi, no experiences there
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 12
- Joined: 18 Apr 2011, 07:38
Re: Virtemart Product Creation
Hello,
The script I wrote is not integrated into Joomla.
It must be run with its URL and its parameters.
It has direct access to tables and VM Phoca Gallery.
Best regards
Ph. Dougoud
The script I wrote is not integrated into Joomla.
It must be run with its URL and its parameters.
It has direct access to tables and VM Phoca Gallery.
Best regards
Ph. Dougoud
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact: