<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; export</title>
	<atom:link href="http://nemops.com/tag/export/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Prestashop: export products without ANY module</title>
		<link>http://nemops.com/prestashop-export-products/</link>
		<comments>http://nemops.com/prestashop-export-products/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 09:26:47 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=637</guid>
		<description><![CDATA[<p>If you were used to needing a Prestashop export products module to export products from your shop, you can finally drop it now. Prestashop 1.5 allows us to export products, and all sort of data, in handy CSV files without any third party module. How? Read on. Prestashop version: 1.5.1 SQL Manager &#8211; What is it? [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-export-products/">Prestashop: export products without ANY module</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>If you were used to needing a Prestashop export products module to export products from your shop, you can finally drop it now. Prestashop 1.5 allows us to export products, and all sort of data, in handy CSV files without any third party module. How? Read on.</p>
<p><span id="more-637"></span></p>
<p><strong>Prestashop version:</strong> 1.5.1</p>
<h2>SQL Manager &#8211; What is it?</h2>
<p><a href="http://nemops.com/wp-content/uploads/2012/10/SQL_Manager.png"><img class="aligncenter size-large wp-image-643" title="Prestashop export products with SQL Manager" src="http://nemops.com/wp-content/uploads/2012/10/SQL_Manager-680x546.png" alt="Prestashop export products with SQL Manager" width="680" height="546" /></a><br />
Those of you who upgraded from 1.4 and spent some time in Prestashop 1.5&#8217;s back office, will have certainly noticed this new feature called <strong>SQL Manager</strong>. If you didn&#8217;t, it can be found under the <strong>Advanced Parameters</strong> tab.</p>
<p>Even though masked under a complex name this is an extremely usefult tool that finally <strong>lets Prestashop export products and all sort of data you can imagine</strong>. Yes, it&#8217;s a bit complicated, but we can finally export all kind of data we need and send it to, for example, price comparison sites or anything else. The cool thing is, we can export data in the exact way we want, choosing the exact stuff we need.</p>
<p><strong>Yes, but how to?</strong> Well, to be honest, there is a reason why this Prestashop export tool has been called SQL Manager. In fact, you have to know a bit of SQL to retrieve the data you want, and this is an enormous obstacle to who doesn&#8217;t even understand a single line of html. <strong>No fear though!</strong> If you only want to export products, I am to provide a simple enough explanation on which query should be used to retrieve values, and which tables are usually storing valuable product data.</p>
<div class="separator"></div>
<h2>The downside &#8211; We can only export CSV</h2>
<p>Yep, no xml export for retrieved data. But, I guess, since Prestashop only natively supports CSV Import, this has been done subsequently. Of course, this does not mean the system can&#8217;t be edited to allow xml export, too!<br />
Furthermore, at this stage we can&#8217;t export images, and the sql query is limited to 1000 characters, which means something will need to be left off in most cases.</p>
<div class="separator"></div>
<h2>Export products: Prestashop SQL Manager example</h2>
<p>In this example, I&#8217;ll be assuming we are exporting data for another Prestashop site, or as a backup for the same store. Therefore I&#8217;ll add most of the information needed by the Prestashop CSV Import tool in my csv. Let&#8217;s see which data is needed by going to <strong>Advanced Parameters -&gt; CSV Import</strong>.</p>
<p><a href="http://nemops.com/wp-content/uploads/2012/10/Available_fields.png"><img class="aligncenter size-full wp-image-656" title="Prestashop Export Products - Available fields" src="http://nemops.com/wp-content/uploads/2012/10/Available_fields.png" alt="Prestashop Export Products - Available fields" width="523" height="736" /></a><br />
A whole bunch of data we need, isn&#8217;t it? So, let&#8217;s start building our query keeping this pag as a reference. Back to the SQL manager, click <strong>Add new</strong>.</p>
<p><a href="http://nemops.com/wp-content/uploads/2012/10/Add_new_Query.png"><img class="aligncenter size-large wp-image-658" title="Add_new_Query" src="http://nemops.com/wp-content/uploads/2012/10/Add_new_Query-680x546.png" alt="" width="680" height="546" /></a></p>
<p>The request can be given a name, so that it can be stored and used again in the future. I&#8217;ll call it &#8220;Product Query&#8221;.</p>
<h3>Step 1 &#8211; Product Table</h3>
<p>Now, let&#8217;s start by grabbing some data from the <strong>ps_product</strong> table. Please note that &#8220;ps_&#8221; is the default prefix, and yours might be different. if this is your case, replace &#8220;ps_&#8221; with your prefix on every occurrence of a table.</p>
<pre class="brush: php; title: ; notranslate">	&quot;SELECT p.id_product, p.active, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
	FROM ps_product p
	GROUP BY p.id_product&quot;</pre>
<p>I&#8217;m using a group by statement to be sure there a re no duplicate products in the final result.</p>
<p>Finally, you&#8217;ll note I had to leave off the field <strong>EAN13, since, for some reason, the SQL manager is not accepting numbers in column names</strong></p>
<p>This is all for the ps_product table. Of course, many things are still missing. Let&#8217;s deal with translatable fields. As you may know, Prestashop only allows us to import one language at time, so we will need to add a condition that tells the query to only look for a specific language. In this case, English has ID #1.</p>
<h3>Step 2 &#8211; Let&#8217;s grab Translatable Fields</h3>
<pre class="brush: php; title: ; notranslate">	&quot;SELECT p.id_product, p.active, &lt;strong&gt;pl.name,&lt;/strong&gt; p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, &lt;strong&gt;pl.description_short,&lt;/strong&gt; &lt;strong&gt;pl.description,&lt;/strong&gt; &lt;strong&gt;pl.meta_title,&lt;/strong&gt; &lt;strong&gt;pl.meta_keywords,&lt;/strong&gt; &lt;strong&gt;pl.meta_description,&lt;/strong&gt; &lt;strong&gt;pl.link_rewrite,&lt;/strong&gt; &lt;strong&gt;pl.available_now,&lt;/strong&gt; &lt;strong&gt;pl.available_later,&lt;/strong&gt; p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
	FROM ps_product p
	&lt;strong&gt;LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product) WHERE pl.id_lang = 1&lt;/strong&gt;&quot;</pre>
<p>So, we added a bunch of terms to look for (the ones in bold) and, after joining the ps_product_lang table, we set the language to be equal to 1, which, as i said, it&#8217;s English. Now, if at this point you find yourself rising a gun at your head because you don&#8217;t understand the code, you can google for mysql, or have a look at <a title="Net Tuts Plus" href="http://net.tutsplus.com">Net Tuts Plus</a> to learn something about mySQL, queries, joins, and so. Of course, you can just copy/paste the end code if all you need is exporting products for a backup, or to another Prestashop store.</p>
<h3>Step 3 &#8211; Dealing with categories</h3>
<p>Let&#8217;s take one step further, things start becoming a bit complicated here</p>
<pre class="brush: php; title: ; notranslate">	&quot;SELECT p.id_product, p.active, pl.name, &lt;strong&gt;GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR &quot;,&quot;) as categories,&lt;/strong&gt; p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
	FROM ps_product p
	LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
	&lt;strong&gt;LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product) LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)&lt;/strong&gt;
	WHERE pl.id_lang = 1
	&lt;strong&gt;AND cl.id_lang = 1&lt;/strong&gt;
	GROUP BY p.id_product&quot;</pre>
<p>At this stage, I&#8217;m retrieving categories as a single value, separated by commas, since it&#8217;s the default separator for multiple values in the Prestashop CSV Import Tool. I also want to make sure I&#8217;m only selecting english category names.</p>
<h3>Step 4 &#8211; Finishing touch</h3>
<p>Finally, if you have multiple shops, don&#8217;t forget to add <strong>AND id_default_shop = 1</strong> for each table which has multiple shops values. In this case, categories and products. Of course, since we didn&#8217;t join the category table before, we must do it now. Be sure to replace the id#1 of the shop i&#8217;ve set, to whatever is the one of the shop you&#8217;re exporting.</p>
<pre class="brush: php; title: ; notranslate">	&quot;SELECT p.id_product, p.active, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR &quot;,&quot;) as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
FROM ps_product p
LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product)
LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)
LEFT JOIN ps_category c ON (cp.id_category = c.id_category)
LEFT JOIN ps_product_tag pt ON (p.id_product = pt.id_product)
WHERE pl.id_lang = 1
AND cl.id_lang = 1
&lt;strong&gt;AND p.id_shop_default = 1 AND c.id_shop_default = 1&lt;/strong&gt;
GROUP BY p.id_product&quot;</pre>
<h3>Step 6 &#8211; What was not exported</h3>
<p>At this stage, the query is complete. Yes, unfortunately <strong>not all of the things needed can be exported using a single query</strong>. For example, images, which are dinamically generated, can&#8217;t be exported with a single query, since there is no url stored in the database. Of course, <strong>if you know a way to do this, please, <a title="Contact me" href="http://nemops.com/contact" target="_blank">let me know</a>, and I will definitely upgrade the guide. </strong>But at any rate, for some weird reason the SQL can only be 1000 chars long, (that&#8217;s way i also had to leave off tags), and therefore something must probably be removed in order to add images in any way.</p>
<p>Also, Prestashop allows us to apply multiple discounts to a single product, isn&#8217;t it? Yeah. Then why is it allowing us to only import one discount per product? I&#8217;ve yet to understand this. Due to this limitation, I&#8217;m not going to export discounts (it would be useless to export something incomplete).</p>
<p>Lastly, note that I am leaving out &#8220;delete existing image&#8221; since there is no place where to retrieve it from. Of course, you should set it to 0 after downloading the csv, or just ignore the field when importing.</p>
<p>Now, to export the CSV, <strong>save</strong>, and back to the SQL Manager page click the little icon as shown below. You can also take a look at the generated results by clicking the magnifier icon.</p>
<p><a href="http://nemops.com/wp-content/uploads/2012/10/Export-products.png"><img class="aligncenter size-large wp-image-664" title="Export-products" src="http://nemops.com/wp-content/uploads/2012/10/Export-products-680x201.png" alt="" width="680" height="201" /></a></p>
<div class="separator"></div>
<h2>Prestashop: export products without any module &#8211; Final Source</h2>
<pre class="brush: php; title: ; notranslate">	&quot;SELECT p.id_product, p.active, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR &quot;,&quot;) as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
FROM ps_product p
LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product)
LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)
LEFT JOIN ps_category c ON (cp.id_category = c.id_category)
LEFT JOIN ps_product_tag pt ON (p.id_product = pt.id_product)
WHERE pl.id_lang = 1
AND cl.id_lang = 1
AND p.id_shop_default = 1
AND c.id_shop_default = 1
GROUP BY p.id_product&quot;</pre>
<p>And this is everything on how to export products in Prestashop without the use of any module. It has some <strong>huge</strong> limitations, but at least it&#8217;s free. As always, if you have questions, feel free to contact me, and I&#8217;ll try to clarify your doubts! And, if you want to learn something more on how to import products using CSV files, you might want to check out my tutorial:<a title="Importing data into your store: Prestashop Import CSV Tool" href="http://nemops.com/prestashop-import-csv/"><strong> Importing data into your store: Prestashop Import CSV Tool</strong></a></p>
<div class="separator">&nbsp;</div>
<h3>Users&#8217; contributions</h3>
<p>Here is a nice addition on how to export tags, by <a href="mailto:yoann@phillips-internet.com">Yoann Masrevery</a>.</p>
<pre class="brush: php; title: ; notranslate">
SELECT ps_product.id_product, GROUP_CONCAT( DISTINCT (
ps_tag.name
)
SEPARATOR ”,” ) AS tags
FROM ps_product
LEFT JOIN ps_product_tag ON ( ps_product.id_product = ps_product_tag.id_product )
LEFT JOIN ps_tag ON ( ps_product_tag.id_tag = ps_tag.id_tag )
GROUP BY ps_product.id_product

</pre>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-export-products/">Prestashop: export products without ANY module</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-export-products/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
	</channel>
</rss>
