Jump to content

Recommended Posts

Bonjour, apres quelque jours de recherche, je souhaite avoir un module gratuit qui permet de passer un woocommerce vers un prestashop

j'ai bien vue des servcice en ligne, mais, je n'ai pas le budget pour cela!

avez vous qqch a me conseiller

Share this post


Link to post
Share on other sites

Bonjour, en gratuit, non.  Si vous ne voulez pas débourser, il faut exporter vos produits en csv (il y a des modules éventuellement) avec les url des images. Puis vous pouvez faire un import dans Prestashop, en faisant matcher les champs du csv avec les champs correspondant. Mais c'est délicat.

Share this post


Link to post
Share on other sites

ok, j'ai créer un petit script en php pour faire le CSV d'import des produits

d'ailleur, je le met ici on ne sais jamais si un jour une personne...

Ce script n'est pas optimisé. Fonctionne vis a vis de mes besoins. Aucune garantie pour la personne qui l'utilisera

<?php

	$serveur = "localhost:12658";
	$base = "WP_PS";
	$user = "root";
	$pass = ""; 

	$mysqli = new mysqli($serveur, $user, $pass, $base);

	$mysqli->set_charset("utf8");

	if ($mysqli->connect_error) {
		die('Erreur de connexion ('.$mysqli->connect_errno.')'. $mysqli->connect_error);
	}

	$chemin = 'migration.csv';
	$delimiteur = ';';

	$query = "SELECT * FROM mod447_posts WHERE post_status = 'publish' AND post_type = 'product'";
	if ($result = $mysqli->query($query)) {
		while ($row = $result->fetch_assoc()) {	
			$catego = 'SELECT mod447_terms.name FROM mod447_term_relationships LEFT JOIN mod447_terms ON mod447_terms.term_id = mod447_term_relationships.term_taxonomy_id LEFT JOIN mod447_term_taxonomy ON mod447_term_taxonomy.term_taxonomy_id = mod447_terms.term_id WHERE mod447_term_relationships.object_id = '.$row['ID'].' AND mod447_term_taxonomy.taxonomy = "product_cat"';
			if ($categos = $mysqli->query($catego)) {
				while ($categor = $categos->fetch_assoc()) {
					// mettre les catégories
					$category = 'FEMME';				
				}
			}
			$price = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$row['ID'].' AND meta_key = "_price" ';
			if ($prices = $mysqli->query($price)) {
				while ($prix = $prices->fetch_assoc()) {
					$pri = $prix['meta_value'];
					echo $pri;
				}
			}
			$sku = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$row['ID'].' AND meta_key = "_sku" ';
			if ($skus = $mysqli->query($sku)) {
				while ($skuss = $skus->fetch_assoc()) {
					$skusss = $skuss['meta_value'];
				}
			}
			$stock = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$row['ID'].' AND meta_key = "_stock" ';
			if ($stocke = $mysqli->query($stock)) {
				while ($stocks = $stocke->fetch_assoc()) {
					$stoque = $stocks['meta_value'];
				}
			}
			
			$query_img = 'SELECT meta_value FROM mod447_postmeta WHERE meta_key ="_thumbnail_id" AND post_id = '.$row['ID'];
			$result_img = $mysqli->query($query_img);
			$img = $result_img -> fetch_assoc();
			$query_img_2 = "SELECT meta_value FROM mod447_postmeta WHERE meta_key ='_wp_attached_file' AND post_id = ".$img['meta_value']."";
			$result_img_2 = $mysqli->query($query_img_2);
			$img_2 = $result_img_2 -> fetch_assoc();
			$image = "https://NOM DE DOMAINE.fr/wp-content/uploads/".$img_2["meta_value"];


			$fichier_csv 	= fopen($chemin, 'w+');
			$lignes[] 		= array(
										$row['ID'], 				// Product ID
										'1',           				// Active (0/1)
										$row['post_title'],			// Name
										$category,					// Category
										$pri,						// Prix TTC
										'1',						// Zone de taxe
										'',							// Wholesale produt
										'1', 						// On sale
										'',							// Discount amount
										'',							// Discount percent
										'',							// Discount from (yyyy-mm-dd)
										'',							// Discount to (yyyy-mm-dd)
										$skusss,					// Reference #
										$skusss,					// Supplier reference #
										'',							// Supplier
										'*******',					// Manufacturer
										'',							// EAN
										'',							// UPC	
										'',							// Ecotax	
										'',							// Width	
										'',							// Height
										'',							// Depth
										'',							// Weight
										$stoque,					// Quantity
										'1',						// Minimal quantity
										'1',						// Low stock level
										'both',						// Visibility
										'',							// Additional shipping cost
										'',							// Unity
										'',							// Unit price
										$row['post_excerpt'],		// Short description
										$row['post_content'],		// Description
										'',							// Tags (x,y,z...)
										$row['post_title'],			// Meta title
										'',							// Meta keywords
										'',							// Meta description
										'',							// URL rewritten
										'In Stock', 				// Text when in stock
										'Current supply. Ordering availlable',// Text when backorder allowed
										'1',						// Available for order (0 = No, 1 = Yes)
										'',							// Product available date
										'',							// Product creation date
										'1',						// Show price (0 = No, 1 = Yes)
										$image,						// Image URLs (x,y,z...)
										$row['post_title'],			// Image alt texts (x,y,z...)
										'1', 						// Delete existing images (0 = No, 1 = Yes)
										'',							// Feature(Name:Value:Position)
										'',							// Available online only (0 = No, 1 = Yes)
										'new',						// Condition
										'',							// Customizable (0 = No, 1 = Yes)
										'',							// Uploadable files (0 = No, 1 = Yes)
										'',							// Text fields (0 = No, 1 = Yes)
										'',							// Out of stock
										'',							// ID / Name of shop
										'',							// Advanced stock management
										'',							// Depends On Stock
										'',							// Warehouse	
									);
			foreach($lignes as $ligne){
				fputcsv($fichier_csv, $ligne, $delimiteur);
			}
			fclose($fichier_csv);
		}
	}		
?>

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

toujours si besoin, je met mon code pour les declinaison / variation

ce code non optimiser, et fonctionne uniquement pour mes besoins a adapter suivent les votres.

bientot les adresses / clients / factures

<?php
	set_time_limit(0);
	ini_set('MAX_EXECUTION_TIME', '-1');

	
	$serveur = "****";
	$base = "*****";
	$user = "***";
	$pass = ""; 
	$mysqli = new mysqli($serveur, $user, $pass, $base);
	$mysqli->set_charset("utf8");
	if ($mysqli->connect_error) {die('Erreur de connexion ('.$mysqli->connect_errno.')'. $mysqli->connect_error);}

	$chemin 						= 	'declinaison.csv';
	$delimiteur 					= 	';';


	$query 							= 	"	SELECT * FROM mod447_posts WHERE post_status = 'publish' AND post_type = 'product' ";
	if ($result 					= 	$mysqli->query($query)) {
		while ($row 				= 	$result->fetch_assoc()) {	
			$ID						=	$row['ID'];
			
			$post_type				= 	'	SELECT ID FROM mod447_posts WHERE post_status = "publish" AND post_type = "product_variation" AND post_parent = '.$ID.' ';
			$result_type 			= 	$mysqli->query($post_type);
			$type 					= 	$result_type -> fetch_assoc();
			$type_ID				=	$type['ID'];
			

			$Query_Variation		=	'	SELECT 	p.ID 		 AS "Product_ID",
													p.post_title AS "Product_Name",
													t.term_id	 AS "Attribute Value ID",
													REPLACE(REPLACE(tt.taxonomy, "pa_", ""), "-", " ") AS "Attribute_Name",
													t.name AS "Attribute_Value"
												FROM mod447_posts AS p
													INNER JOIN mod447_term_relationships AS tr ON p.ID = tr.object_id
													INNER JOIN mod447_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_id
														AND tt.taxonomy LIKE "pa_%"
													INNER JOIN mod447_terms AS t ON tr.term_taxonomy_id = t.term_id
														WHERE p.post_type = "product"
															AND p.post_status = "publish"
																AND p.ID = '.$ID.' ';
			if ($result_variation	= 	$mysqli->query($Query_Variation)) {
				while ($variation	= 	$result_variation->fetch_assoc()) {

					$Value_Position = 	'';
					$Position		=	'';

					if(isset($variation['Attribute_Name']) && $variation['Attribute_Name'] === "taille" ) { 
							$Value_Position = $variation['Attribute_Value'].':0' ; 
							$Position = $variation['Attribute_Name'].':0';
					}
					if(isset($variation['Attribute_Name']) && $variation['Attribute_Name'] === "longueur" ) {
						$Value_Position = $variation['Attribute_Value'].':0' ;
						$Position = $variation['Attribute_Name'].':0';
					}
					
					$sku = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$type_ID.' AND meta_key = "_sku" ';
					if ($skus = $mysqli->query($sku)) {
						while ($skuss = $skus->fetch_assoc()) {
							$skusss = $skuss['meta_value'];
						}
					}
					
					$price = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$type_ID.' AND meta_key = "_price" ';
					if ($prices = $mysqli->query($price)) {
						while ($prix = $prices->fetch_assoc()) {
							$pri = $prix['meta_value'];
						}
					}
					$stock = 'SELECT meta_value FROM mod447_postmeta WHERE post_id = '.$type_ID.' AND meta_key = "_stock" ';
					if ($stocke = $mysqli->query($stock)) {
						while ($stocks = $stocke->fetch_assoc()) {
							$stoque = $stocks['meta_value'];
						}
					}

					sleep(2);
					echo $ID.'<br>';

				$fichier_csv 	= fopen($chemin, 'w+');
				$lignes[] 		= array(
											$ID,					// Product ID*
											$Position,				// Attribute (Name:Type:Position)*
											$Value_Position,		// Value (Value:Position)*
											$skusss,				// Supplier reference
											$pri,					// Wholesale price
											$stoque				// Quantity

					);
				foreach($lignes as $ligne){
					fputcsv($fichier_csv, $ligne, $delimiteur);
				}
				fclose($fichier_csv);
			}
		}
	} 
}		
			

			

		
?>

 

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More